diff --git a/docs/manual/intro.tex b/docs/manual/intro.tex index 8f476a0bd..a71e44f32 100644 --- a/docs/manual/intro.tex +++ b/docs/manual/intro.tex @@ -352,7 +352,6 @@ \subsection{Simple SLEPc Example} MatCreate(MPI_Comm comm,Mat *A); MatSetSizes(Mat A,PetscInt m,PetscInt n,PetscInt M,PetscInt N); MatSetFromOptions(Mat A); - MatSetUp(Mat A); \end{Verbatim} where the matrix format can be specified at runtime. The example creates a matrix, sets the nonzero values with \rutina{MatSetValues} and then assembles it. diff --git a/gmakefile b/gmakefile index 271a4776a..d59d14a13 100644 --- a/gmakefile +++ b/gmakefile @@ -50,6 +50,7 @@ libslepcall := $(if $(filter-out no,$(BUILDSHAREDLIB)),$(libslepcall_shared),$(l generated := $(PETSC_ARCH)/lib/slepc/conf/files slepc_libs : $(libslepcall) + .PHONY: slepc_libs .SECONDEXPANSION: # to expand $$(@D)/.DIR @@ -61,7 +62,7 @@ $(generated) : $(slepcconf) $(slepcvariables) $(PETSCCONFIGDIR)/gmakegen.py $(PYTHON) $(PETSCCONFIGDIR)/gmakegen.py --petsc-arch=$(PETSC_ARCH_DIR) --pkg-dir=$(SLEPC_DIR) --pkg-name=slepc --pkg-pkgs=$(spkgs) --pkg-arch=$(PETSC_ARCH) # Skip including generated files (which triggers rebuilding them) when we're just going to clean anyway. -ifneq ($(filter-out alletags deletefortranstubs allfortranstubs allfortranstubsinplace help clean check info gmakeinfo,$(MAKECMDGOALS:clean%=clean)),) +ifneq ($(filter-out help clean distclean check info gmakeinfo checkbadSource deletefortranstubs allfortranstubs allfortranstubsinplace alletags lint_slepc get%,$(MAKECMDGOALS:clean%=clean)),) include $(generated) endif @@ -144,7 +145,7 @@ define ARCHIVE_RECIPE_DEFAULT endef %.$(AR_LIB_SUFFIX) : $$(obj) | $$(@D)/.DIR - $(if $(findstring win_lib,$(AR)),$(ARCHIVE_RECIPE_WIN32FE_LIB),$(if $(findstring yes,$(AR_ARGFILE)),$(if $(GMAKE4),$(ARCHIVE_RECIPE_ARGFILE),$(ARCHIVE_RECIPE_DEFAULT)),$(ARCHIVE_RECIPE_DEFAULT))) + $(if $(findstring win32fe_lib,$(AR)),$(ARCHIVE_RECIPE_WIN32FE_LIB),$(if $(findstring yes,$(AR_ARGFILE)),$(if $(GMAKE4),$(ARCHIVE_RECIPE_ARGFILE),$(ARCHIVE_RECIPE_DEFAULT)),$(ARCHIVE_RECIPE_DEFAULT))) # with-single-library=0 libpkg = $(foreach pkg, $1, $(LIBDIR)/libslepc$(pkg).$(SL_LINKER_SUFFIX)) @@ -231,7 +232,7 @@ $(OBJDIR)/src/mfn/f90-mod/slepcmfnmod.o : $(OBJDIR)/src/sys/classes/bv/f90-mod $(OBJDIR)/src/lme/f90-mod/slepclmemod.o : $(OBJDIR)/src/sys/classes/bv/f90-mod/slepcbvmod.o $(OBJDIR)/src/eps/f90-mod/slepcepsmod.o : $(OBJDIR)/src/sys/classes/bv/f90-mod/slepcbvmod.o $(OBJDIR)/src/sys/classes/fn/f90-mod/slepcfnmod.o $(OBJDIR)/src/sys/classes/ds/f90-mod/slepcdsmod.o $(OBJDIR)/src/sys/classes/rg/f90-mod/slepcrgmod.o $(OBJDIR)/src/sys/classes/st/f90-mod/slepcstmod.o $(OBJDIR)/src/lme/f90-mod/slepclmemod.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/nep/f90-mod/slepcnepmod.o : $(OBJDIR)/src/pep/f90-mod/slepcpepmod.o $(OBJDIR)/src/mfn/f90-mod/slepcmfnmod.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.) @@ -283,22 +284,37 @@ gmakeinfo: -@echo "-----------------------------------------" -@echo "Using C/C++ include paths: ${SLEPC_CC_INCLUDES}" -@echo "Using C compile: ${PETSC_CCOMPILE_SINGLE}" - -@if [ "${CXX}" != "" ]; then \ - echo "Using C++ compile: ${PETSC_CXXCOMPILE_SINGLE}";\ - fi + -@if [ "${MPICC_SHOW}" != "" ]; then \ + printf "mpicc -show: %b\n" "${MPICC_SHOW}";\ + fi; \ + printf "C compiler version: %b\n" "${C_VERSION}"; \ + if [ "${CXX}" != "" ]; then \ + echo "Using C++ compile: ${PETSC_CXXCOMPILE_SINGLE}";\ + if [ "${MPICXX_SHOW}" != "" ]; then \ + printf "mpicxx -show: %b\n" "${MPICXX_SHOW}"; \ + fi;\ + printf "C++ compiler version: %b\n" "${Cxx_VERSION}"; \ + fi -@if [ "${FC}" != "" ]; then \ echo "Using Fortran include/module paths: ${SLEPC_FC_INCLUDES}";\ echo "Using Fortran compile: ${PETSC_FCOMPILE_SINGLE}";\ + if [ "${MPIFC_SHOW}" != "" ]; then \ + printf "mpif90 -show: %b\n" "${MPIFC_SHOW}"; \ + fi; \ + printf "Fortran compiler version: %b\n" "${FC_VERSION}"; \ fi -@if [ "${CUDAC}" != "" ]; then \ - echo "Using CUDA compile: ${PETSC_CUCOMPILE_SINGLE}";\ + echo "Using CUDA compile: ${PETSC_CUCOMPILE_SINGLE}";\ fi + -@if [ "${CLANGUAGE}" = "CXX" ]; then \ + echo "Using C++ compiler to compile PETSc";\ + 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}";\ + echo "Using Fortran linker: ${FC_LINKER}";\ + echo "Using Fortran flags: ${FC_LINKER_FLAGS}";\ fi -@echo "-----------------------------------------" -@echo "Using libraries: ${SLEPC_LIB}" diff --git a/gmakefile.test b/gmakefile.test index 40df21907..198d15c55 100644 --- a/gmakefile.test +++ b/gmakefile.test @@ -7,7 +7,7 @@ CONFIGDIR := $(SLEPC_DIR)/config # TESTSRCDIR is always relative to gmakefile.test # This must be before includes mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) -TESTSRCDIR := $(dir $(mkfile_path))src +TESTSRCDIR ?= $(dir $(mkfile_path))src -include $(SLEPC_DIR)/$(PETSC_ARCH)/lib/slepc/conf/slepcvariables -include $(SLEPC_DIR)/lib/slepc/conf/slepc_variables @@ -116,7 +116,7 @@ endif $(generatedtest) : $(slepcconf) $(slepcvariables) $(PETSCCONFIGDIR)/gmakegentest.py $(TESTDIR)/.DIR | $$(@D)/.DIR $(PYTHON) $(PETSCCONFIGDIR)/gmakegentest.py --petsc-dir=$(PETSC_DIR) --petsc-arch=$(PETSC_ARCH_DIR) --testdir=$(TESTDIR) --srcdir=$(TESTSRCDIR) --pkg-name=slepc --pkg-pkgs=$(spkgs) --pkg-arch=$(PETSC_ARCH) --pkg-dir=$(SLEPC_DIR) -ifneq ($(filter-out help clean check info gmakeinfo slepc_libs all install install-lib checkbadSource checkbadFileChange deletefortranstubs allfortranstubs allfortranstubsinplace alletags get%,$(MAKECMDGOALS:clean%=clean)),) +ifneq ($(filter-out help clean distclean check info gmakeinfo slepc_libs all install install-lib checkbadSource deletefortranstubs allfortranstubs allfortranstubsinplace alletags lint_slepc get%,$(MAKECMDGOALS:clean%=clean)),) include $(generatedtest) endif @@ -159,6 +159,7 @@ endif # The solution is not ideal in the sense we have to duplicate the same workaround to any external libraries # using C++17 inline static variables. We have to wait for GNU to clarify this issue. PETSC_COMPILE.kokkos.cxx = $(filter-out -fvisibility=hidden,$(subst -Xcompiler -fvisibility=hidden ,,$(strip $(KOKKOS_COMPILE)))) +KOKKOS_LINKER = $(filter-out -fvisibility=hidden,$(subst -Xcompiler -fvisibility=hidden ,,$(strip $(CLINKER)))) ifneq ($(RAJA_USE_CUDA_COMPILER),) PETSC_COMPILE.raja.cxx = ${CUDAC} $(MPICXX_INCLUDES) ${CUDAC_FLAGS} -x cu -Xcudafe "--display_error_number" -c --compiler-options="${PETSC_CXXCPPFLAGS} ${PETSC_CC_INCLUDES} ${CUDA_CXXFLAGS}" --expt-extended-lambda --expt-relaxed-constexpr @@ -271,7 +272,7 @@ $(testexe.hip.cpp) : $(TESTDIR)/% : $(TESTDIR)/%.o $$^ $(libpetscall) -$(call macos-firewall-register,$@) $(testexe.kokkos.cxx) : $(TESTDIR)/% : $(TESTDIR)/%.o $$^ $(libslepcall) - $(call quiet,CLINKER) $(EXEFLAGS) -o $@ $^ $(SLEPC_TEST_LIB) + $(call quiet,KOKKOS_LINKER) $(EXEFLAGS) -o $@ $^ $(SLEPC_TEST_LIB) -$(call macos-firewall-register,$@) $(testexe.raja.cxx) : $(TESTDIR)/% : $(TESTDIR)/%.o $$^ $(libpetscall) @@ -433,7 +434,7 @@ help: help-make ${helpdeps} help-make: -@echo -@echo "SLEPc makefile basic usage:" - -@echo " make rule " + -@echo " ${OMAKE} rule " -@echo help-nontest: @@ -453,13 +454,17 @@ help-nontest: -@echo " test - use \"make -f gmakefile.test help\" for help on running the extensive tests" -@echo -@echo "Developer rules:" - -@echo " clean - delete libraries and Fortran module files" + -@echo " clean - delete libraries and Fortran module files (used in $SLEPC_DIR)" -@echo " lint_slepc - run lint on the source code, including its embedded documentation" + -@echo " delete compiled examples, .o and related files (used in tutorials or test directories)" -@echo " allfortranstubs - regenerate Fortran stubs/interface definitions, needed after git pulls or source code changes" -@echo " deletefortranstubs - delete the generated Fortran stubs/interface definitions" -@echo " checkbadSource - check the source code for violations of coding standards" -@echo " abitest - Compare ABI/API of two versions of SLEPc library with the old one defined by SLEPC_DIR_ABI_OLD and PETSC_{DIR,ARCH}_ABI_OLD" -@echo " reconfigure - delete libraries and Fortran module files and run the previously run configure again" + -@echo " lint_slepc - run lint on the source code, including its embedded documentation" + -@echo " Run \"${OMAKE} help-lint\" for lint options" + -@echo " " -@echo " " help-test: diff --git a/include/slepc/private/bvimpl.h b/include/slepc/private/bvimpl.h index f744a0c31..9f3adf511 100644 --- a/include/slepc/private/bvimpl.h +++ b/include/slepc/private/bvimpl.h @@ -212,7 +212,6 @@ static inline PetscErrorCode BV_SetMatrixDiagonal(BV bv,Vec vomega,Mat M) PetscCall(MatCreate(PetscObjectComm((PetscObject)bv),&Omega)); PetscCall(MatSetSizes(Omega,bv->n,bv->n,bv->N,bv->N)); PetscCall(MatSetType(Omega,Mtype)); - PetscCall(MatSetUp(Omega)); PetscCall(MatDiagonalSet(Omega,vomega,INSERT_VALUES)); PetscCall(BVSetMatrix(bv,Omega,PETSC_TRUE)); PetscCall(MatDestroy(&Omega)); diff --git a/include/slepcds.h b/include/slepcds.h index 7c201bf4d..5349b0a32 100644 --- a/include/slepcds.h +++ b/include/slepcds.h @@ -195,6 +195,7 @@ SLEPC_EXTERN PetscErrorCode DSSynchronize(DS,PetscScalar*,PetscScalar*); PETSC_DEPRECATED_FUNCTION(3, 18, 0, "DSGetMat()+MatDenseGetSubMatrix()+MatCopy()", ) static inline PetscErrorCode DSCopyMat(DS ds,DSMatType m,PetscInt mr,PetscInt mc,Mat A,PetscInt Ar,PetscInt Ac,PetscInt rows,PetscInt cols,PetscBool out) { Mat M,M0,A0; + PetscFunctionBegin; PetscCall(DSGetMat(ds,m,&M)); PetscCall(MatDenseGetSubMatrix(M,mr,mr+rows,mc,mc+cols,&M0)); diff --git a/include/slepcmat.h b/include/slepcmat.h index 9ad0a8199..72419092e 100644 --- a/include/slepcmat.h +++ b/include/slepcmat.h @@ -25,6 +25,7 @@ SLEPC_EXTERN PetscErrorCode MatNormEstimate(Mat,Vec,Vec,PetscReal*); PETSC_DEPRECATED_FUNCTION(3, 6, 0, "MatCreateRedundantMatrix() followed by MatConvert()", ) static inline PetscErrorCode SlepcMatConvertSeqDense(Mat mat,Mat *newmat) { Mat Ar; + PetscFunctionBegin; PetscCall(MatCreateRedundantMatrix(mat,0,PETSC_COMM_SELF,MAT_INITIAL_MATRIX,&Ar)); PetscCall(MatConvert(Ar,MATSEQDENSE,MAT_INITIAL_MATRIX,newmat)); diff --git a/include/slepcst.h b/include/slepcst.h index 2601f4c6d..130aeb4fd 100644 --- a/include/slepcst.h +++ b/include/slepcst.h @@ -72,6 +72,7 @@ PETSC_DEPRECATED_FUNCTION(3, 15, 0, "STGetMatrixTransformed()", ) static inline PETSC_DEPRECATED_FUNCTION(3, 15, 0, "STGetOperator() followed by MatComputeOperator()", ) static inline PetscErrorCode STComputeExplicitOperator(ST st,Mat *A) { Mat Op; + PetscFunctionBegin; PetscCall(STGetOperator(st,&Op)); PetscCall(MatComputeOperator(Op,MATAIJ,A)); diff --git a/include/slepcversion.h b/include/slepcversion.h index 87e841393..715cdaeab 100644 --- a/include/slepcversion.h +++ b/include/slepcversion.h @@ -14,7 +14,7 @@ #define SLEPC_VERSION_RELEASE 0 #define SLEPC_VERSION_MAJOR 3 #define SLEPC_VERSION_MINOR 20 -#define SLEPC_VERSION_SUBMINOR 1 +#define SLEPC_VERSION_SUBMINOR 2 #define SLEPC_RELEASE_DATE "September 29, 2023" #define SLEPC_VERSION_DATE "unknown" diff --git a/lib/slepc/bin/maint/fixinclude.py b/lib/slepc/bin/maint/fixinclude.py index 8bffcc600..c507de2cd 100755 --- a/lib/slepc/bin/maint/fixinclude.py +++ b/lib/slepc/bin/maint/fixinclude.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Used by the makefile lib/petsc/conf/rules html to replace #includes in the source files with links when possible diff --git a/lib/slepc/bin/maint/generateetags.py b/lib/slepc/bin/maint/generateetags.py index fdbdcc975..952ddb383 100755 --- a/lib/slepc/bin/maint/generateetags.py +++ b/lib/slepc/bin/maint/generateetags.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -#!/bin/env python3 # # 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 @@ -147,7 +146,7 @@ def main(ctags): ctagfile = None flist = [] if os.path.isdir('.git'): - output = subprocess.check_output('git ls-files | grep -E -v \(^\(docs/\|share/slepc/datafiles/\)\|/output/\|\.\(png\|pdf\|ps\|ppt\|jpg\|tex\)$\)', shell=True) + output = subprocess.check_output(f'git ls-files | grep -E -v \(^\(docs/\|share/slepc/datafiles/\)\|/output/\|\.\(png\|pdf\|ps\|ppt\|jpg\|tex\)$\)', shell=True) flist = output.decode(sys.getfilesystemencoding()).splitlines() else: for dirpath, dirnames, filenames in os.walk(os.getcwd()): diff --git a/lib/slepc/bin/maint/generatefortranstubs.py b/lib/slepc/bin/maint/generatefortranstubs.py index e1c2d60c7..f74db9d41 100644 --- a/lib/slepc/bin/maint/generatefortranstubs.py +++ b/lib/slepc/bin/maint/generatefortranstubs.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -#!/bin/env python3 # # Generates fortran stubs for PETSc using the Sowing bfort program # diff --git a/lib/slepc/bin/maint/wwwindex.py b/lib/slepc/bin/maint/wwwindex.py index 79e90e7f7..18c00d7c7 100755 --- a/lib/slepc/bin/maint/wwwindex.py +++ b/lib/slepc/bin/maint/wwwindex.py @@ -1,5 +1,4 @@ -#!/usr/bin/env python -#!/bin/env python +#!/usr/bin/env python3 """ Reads in all the generated manual pages, and creates the index for the manualpages, ordering the indices into sections based diff --git a/makefile b/makefile index b9749641a..701dce854 100644 --- a/makefile +++ b/makefile @@ -44,7 +44,7 @@ all: @ln -sf ${PETSC_ARCH}/lib/slepc/conf/make.log make.log +@${OMAKE_SELF_PRINTDIR} PETSC_ARCH=${PETSC_ARCH} PETSC_DIR=${PETSC_DIR} SLEPC_DIR=${SLEPC_DIR} all-local 2>&1 | tee -a ${PETSC_ARCH}/lib/slepc/conf/make.log; @grep -E '(out of memory allocating.*after a total of|gfortran: fatal error: Killed signal terminated program f951|f95: fatal error: Killed signal terminated program f951)' ${PETSC_ARCH}/lib/slepc/conf/make.log | tee ${PETSC_ARCH}/lib/slepc/conf/memoryerror.log > /dev/null - @grep -E -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 + @grep -v "using error" ${PETSC_ARCH}/lib/slepc/conf/make.log > /dev/null | grep -E -i "( error | error: |no such file or directory)" | tee ./${PETSC_ARCH}/lib/slepc/conf/error.log +@if test -s ${PETSC_ARCH}/lib/slepc/conf/memoryerror.log; then \ printf ${PETSC_TEXT_HILIGHT}"**************************ERROR*************************************\n" 2>&1 | tee -a ${PETSC_ARCH}/lib/slepc/conf/make.log; \ echo " Error during compile, you need to increase the memory allocated to the VM and rerun " 2>&1 | tee -a ${PETSC_ARCH}/lib/slepc/conf/make.log; \ diff --git a/setup.py b/setup.py index c94ad8b85..ad220fa17 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """ SLEPc: Scalable Library for Eigenvalue Problem Computations diff --git a/share/slepc/Makefile.user b/share/slepc/Makefile.user index 378dfd4e4..07279e4e1 100644 --- a/share/slepc/Makefile.user +++ b/share/slepc/Makefile.user @@ -8,23 +8,23 @@ petsc.pc := $(PETSC_DIR)/$(PETSC_ARCH)/lib/pkgconfig/petsc.pc slepc.pc := $(SLEPC_DIR)/$(PETSC_ARCH)/lib/pkgconfig/slepc.pc # Additional libraries that support pkg-config can be added to the list of PACKAGES below. -PACKAGES := $(petsc.pc) $(slepc.pc) +PACKAGES := $(slepc.pc) -CC := $(shell pkg-config --variable=ccompiler $(PACKAGES)) -CXX := $(shell pkg-config --variable=cxxcompiler $(PACKAGES)) -FC := $(shell pkg-config --variable=fcompiler $(PACKAGES)) -CFLAGS_OTHER := $(shell pkg-config --cflags-only-other $(PACKAGES)) -CFLAGS := $(shell pkg-config --variable=cflags_extra $(PACKAGES)) $(CFLAGS_OTHER) -CXXFLAGS := $(shell pkg-config --variable=cxxflags_extra $(PACKAGES)) $(CFLAGS_OTHER) -FFLAGS := $(shell pkg-config --variable=fflags_extra $(PACKAGES)) +CC := $(shell pkg-config --variable=ccompiler $(petsc.pc)) +CXX := $(shell pkg-config --variable=cxxcompiler $(petsc.pc)) +FC := $(shell pkg-config --variable=fcompiler $(petsc.pc)) +CFLAGS_OTHER := $(shell pkg-config --cflags-only-other $(petsc.pc)) +CFLAGS := $(shell pkg-config --variable=cflags_extra $(petsc.pc)) $(CFLAGS_OTHER) +CXXFLAGS := $(shell pkg-config --variable=cxxflags_extra $(petsc.pc)) $(CFLAGS_OTHER) +FFLAGS := $(shell pkg-config --variable=fflags_extra $(petsc.pc)) CPPFLAGS := $(shell pkg-config --cflags-only-I $(PACKAGES)) LDFLAGS := $(shell pkg-config --libs-only-L --libs-only-other $(PACKAGES)) LDFLAGS += $(patsubst -L%, $(shell pkg-config --variable=ldflag_rpath $(petsc.pc))%,$(shell pkg-config --libs-only-L $(PACKAGES))) LDLIBS := $(shell pkg-config --libs-only-l $(PACKAGES)) -lm -CUDAC := $(shell pkg-config --variable=cudacompiler $(PACKAGES)) -CUDAC_FLAGS := $(shell pkg-config --variable=cudaflags_extra $(PACKAGES)) -CUDA_LIB := $(shell pkg-config --variable=cudalib $(PACKAGES)) -CUDA_INCLUDE := $(shell pkg-config --variable=cudainclude $(PACKAGES)) +CUDAC := $(shell pkg-config --variable=cudacompiler $(petsc.pc)) +CUDAC_FLAGS := $(shell pkg-config --variable=cudaflags_extra $(petsc.pc)) +CUDA_LIB := $(shell pkg-config --variable=cudalib $(petsc.pc)) +CUDA_INCLUDE := $(shell pkg-config --variable=cudainclude $(petsc.pc)) print: @echo CC=$(CC) diff --git a/src/binding/slepc4py/CHANGES.rst b/src/binding/slepc4py/CHANGES.rst index 87a06f748..c0d6850b1 100644 --- a/src/binding/slepc4py/CHANGES.rst +++ b/src/binding/slepc4py/CHANGES.rst @@ -6,6 +6,12 @@ CHANGES: SLEPc for Python :Contact: dalcinl@gmail.com +Release 3.20.2 +============== + +- Update to SLEPc 3.20.2. + + Release 3.20.1 ============== diff --git a/src/binding/slepc4py/conf/cythonize.py b/src/binding/slepc4py/conf/cythonize.py index 499146aae..4c2467059 100755 --- a/src/binding/slepc4py/conf/cythonize.py +++ b/src/binding/slepc4py/conf/cythonize.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """Run Cython with custom options.""" import os import sys diff --git a/src/binding/slepc4py/conf/epydoc.cfg b/src/binding/slepc4py/conf/epydoc.cfg index 63a95a147..3f2953e73 100644 --- a/src/binding/slepc4py/conf/epydoc.cfg +++ b/src/binding/slepc4py/conf/epydoc.cfg @@ -66,7 +66,7 @@ imports: no # the output (HTML only). sourcecode: no -# Whether or not to include a a page with Epydoc log, containing +# Whether or not to include a page with Epydoc log, containing # effective option at the time of generation and the reported logs. include-log: no diff --git a/src/binding/slepc4py/setup.py b/src/binding/slepc4py/setup.py index 3dcfa1087..3d773f3da 100755 --- a/src/binding/slepc4py/setup.py +++ b/src/binding/slepc4py/setup.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Author: Lisandro Dalcin # Contact: dalcinl@gmail.com diff --git a/src/binding/slepc4py/src/slepc4py/__init__.py b/src/binding/slepc4py/src/slepc4py/__init__.py index 4ac447d8d..cb32fd21e 100644 --- a/src/binding/slepc4py/src/slepc4py/__init__.py +++ b/src/binding/slepc4py/src/slepc4py/__init__.py @@ -21,7 +21,7 @@ """ __author__ = 'Lisandro Dalcin' -__version__ = '3.20.1' +__version__ = '3.20.2' __credits__ = 'SLEPc Team ' # ----------------------------------------------------------------------------- diff --git a/src/eps/impls/davidson/davidson.h b/src/eps/impls/davidson/davidson.h index f05f311cf..c05a3746a 100644 --- a/src/eps/impls/davidson/davidson.h +++ b/src/eps/impls/davidson/davidson.h @@ -203,7 +203,7 @@ static inline PetscErrorCode EPSDavidsonFLCall(dvdFunctionList *fl,dvdDashboard dvdFunctionList *l; PetscFunctionBegin; - for (l=fl;l;l=l->next) PetscCall((l->f)(d)); + for (l=fl;l;l=l->next) PetscCall(l->f(d)); PetscFunctionReturn(PETSC_SUCCESS); } diff --git a/src/eps/impls/davidson/dvdcalcpairs.c b/src/eps/impls/davidson/dvdcalcpairs.c index f26f9ba74..538e81c51 100644 --- a/src/eps/impls/davidson/dvdcalcpairs.c +++ b/src/eps/impls/davidson/dvdcalcpairs.c @@ -348,7 +348,7 @@ static PetscErrorCode dvd_calcpairs_apply_arbitrary(dvdDashboard *d,PetscInt r_s xi = NULL; if (d->nX[i] != 1.0) PetscCall(VecScale(xr,1.0/d->nX[i])); #endif - PetscCall((d->eps->arbitrary)(rr[i-r_s],ri[i-r_s],xr,xi,&rr[i-r_s],&ri[i-r_s],d->eps->arbitraryctx)); + PetscCall(d->eps->arbitrary(rr[i-r_s],ri[i-r_s],xr,xi,&rr[i-r_s],&ri[i-r_s],d->eps->arbitraryctx)); #if !defined(PETSC_USE_COMPLEX) if (i != k) { rr[i+1-r_s] = rr[i-r_s]; @@ -496,7 +496,7 @@ static PetscErrorCode dvd_calcpairs_proj_res(dvdDashboard *d,PetscInt r_s,PetscI PetscCall(BVSetActiveColumns(cX,0,l)); for (i=0;inR[r_s+i],&lindep)); PetscCall(BVSetActiveColumns(cX,l,k)); - if (lindep || (PetscAbs(d->nR[r_s+i]) < PETSC_MACHINE_EPSILON)) PetscCall(PetscInfo(d->eps,"The computed eigenvector residual %" PetscInt_FMT " is too low, %g!\n",r_s+i,(double)(d->nR[r_s+i]))); + if (lindep || (PetscAbs(d->nR[r_s+i]) < PETSC_MACHINE_EPSILON)) PetscCall(PetscInfo(d->eps,"The computed eigenvector residual %" PetscInt_FMT " is too low, %g!\n",r_s+i,(double)d->nR[r_s+i])); } else { for (i=0;inR[r_s+i])); for (i=0;inR[r_s+i])); diff --git a/src/eps/impls/external/arpack/arpack.c b/src/eps/impls/external/arpack/arpack.c index aea671ab2..b2604bd8e 100644 --- a/src/eps/impls/external/arpack/arpack.c +++ b/src/eps/impls/external/arpack/arpack.c @@ -178,7 +178,7 @@ static PetscErrorCode EPSSolve_ARPACK(EPS eps) PetscCall(VecPlaceArray(y,&ar->workd[ipntr[1]-1])); if (ido == -1) { - /* Y = OP * X for for the initialization phase to + /* Y = OP * X for the initialization phase to force the starting vector into the range of OP */ PetscCall(STApply(eps->st,x,y)); } else if (ido == 2) { @@ -213,7 +213,7 @@ static PetscErrorCode EPSSolve_ARPACK(EPS eps) eps->nconv = iparam[4]; eps->its = iparam[2]; - PetscCheck(info!=3,PetscObjectComm((PetscObject)eps),PETSC_ERR_LIB,"No shift could be applied in xxAUPD.\nTry increasing the size of NCV relative to NEV"); + PetscCheck(info!=3,PetscObjectComm((PetscObject)eps),PETSC_ERR_LIB,"No shift could be applied in xxAUPD. Try increasing the size of NCV relative to NEV"); PetscCheck(info==0 || info==1,PetscObjectComm((PetscObject)eps),PETSC_ERR_LIB,"Error reported by ARPACK subroutine xxAUPD (%" PetscInt_FMT ")",info); rvec = PETSC_TRUE; diff --git a/src/eps/impls/krylov/krylovschur/ks-slice.c b/src/eps/impls/krylov/krylovschur/ks-slice.c index 77581e222..2d4abb2cf 100644 --- a/src/eps/impls/krylov/krylovschur/ks-slice.c +++ b/src/eps/impls/krylov/krylovschur/ks-slice.c @@ -136,7 +136,7 @@ static PetscErrorCode EPSSliceAllocateSolution(EPS eps,PetscInt extra) PetscCall(BVDestroy(&sr->V)); PetscCall(BVCreate(PetscObjectComm((PetscObject)eps),&sr->V)); if (!eps->V) PetscCall(EPSGetBV(eps,&eps->V)); - if (!((PetscObject)(eps->V))->type_name) PetscCall(BVSetType(sr->V,BVMAT)); + if (!((PetscObject)eps->V)->type_name) PetscCall(BVSetType(sr->V,BVMAT)); else { PetscCall(BVGetType(eps->V,&type)); PetscCall(BVSetType(sr->V,type)); @@ -199,7 +199,7 @@ static PetscErrorCode EPSSliceGetEPS(EPS eps) PetscCall(EPSGetBV(ctx->eps,&V)); PetscCall(BVGetRandomContext(V,&rand)); /* make sure the random context is available when duplicating */ if (!eps->V) PetscCall(EPSGetBV(eps,&eps->V)); - if (!((PetscObject)(eps->V))->type_name) PetscCall(BVSetType(V,BVMAT)); + if (!((PetscObject)eps->V)->type_name) PetscCall(BVSetType(V,BVMAT)); else { PetscCall(BVGetType(eps->V,&type)); PetscCall(BVSetType(V,type)); @@ -289,7 +289,7 @@ PetscErrorCode EPSSetUp_KrylovSchur_Slice(EPS eps) EPSCheckUnsupportedCondition(eps,EPS_FEATURE_ARBITRARY | EPS_FEATURE_REGION | EPS_FEATURE_STOPPING,PETSC_TRUE," with spectrum slicing"); EPSCheckIgnoredCondition(eps,EPS_FEATURE_BALANCE,PETSC_TRUE," with spectrum slicing"); if (eps->tol==(PetscReal)PETSC_DEFAULT) { - #if defined(PETSC_USE_REAL_SINGLE) +#if defined(PETSC_USE_REAL_SINGLE) eps->tol = SLEPC_DEFAULT_TOL; #else /* use tighter tolerance */ @@ -415,17 +415,17 @@ PetscErrorCode EPSSetUp_KrylovSchur_Slice(EPS eps) PetscCallMPI(MPI_Comm_rank(child,&rank)); if (!rank) { if (sr->inertia0!=-1 && ((sr->dir>0 && ctx->subc->color>0) || (sr->dir<0 && ctx->subc->colornpart-1))) { /* send inertia0 to neighbour0 */ - PetscCallMPI(MPI_Isend(&(sr->inertia0),1,MPIU_INT,ctx->subc->color-sr->dir,0,ctx->commrank,&req)); - PetscCallMPI(MPI_Isend(&(sr->int0),1,MPIU_REAL,ctx->subc->color-sr->dir,0,ctx->commrank,&req)); + PetscCallMPI(MPI_Isend(&sr->inertia0,1,MPIU_INT,ctx->subc->color-sr->dir,0,ctx->commrank,&req)); + PetscCallMPI(MPI_Isend(&sr->int0,1,MPIU_REAL,ctx->subc->color-sr->dir,0,ctx->commrank,&req)); } if ((sr->dir>0 && ctx->subc->colornpart-1)|| (sr->dir<0 && ctx->subc->color>0)) { /* receive inertia1 from neighbour1 */ - PetscCallMPI(MPI_Recv(&(sr->inertia1),1,MPIU_INT,ctx->subc->color+sr->dir,0,ctx->commrank,MPI_STATUS_IGNORE)); - PetscCallMPI(MPI_Recv(&(sr->int1),1,MPIU_REAL,ctx->subc->color+sr->dir,0,ctx->commrank,MPI_STATUS_IGNORE)); + PetscCallMPI(MPI_Recv(&sr->inertia1,1,MPIU_INT,ctx->subc->color+sr->dir,0,ctx->commrank,MPI_STATUS_IGNORE)); + PetscCallMPI(MPI_Recv(&sr->int1,1,MPIU_REAL,ctx->subc->color+sr->dir,0,ctx->commrank,MPI_STATUS_IGNORE)); } if (sr->inertia0==-1 && !(sr->dir>0 && ctx->subc->color==ctx->npart-1) && !(sr->dir<0 && ctx->subc->color==0)) { sr->inertia0 = sr->inertia1; sr->int0 = sr->int1; - PetscCallMPI(MPI_Isend(&(sr->inertia0),1,MPIU_INT,ctx->subc->color-sr->dir,0,ctx->commrank,&req)); - PetscCallMPI(MPI_Isend(&(sr->int0),1,MPIU_REAL,ctx->subc->color-sr->dir,0,ctx->commrank,&req)); + PetscCallMPI(MPI_Isend(&sr->inertia0,1,MPIU_INT,ctx->subc->color-sr->dir,0,ctx->commrank,&req)); + PetscCallMPI(MPI_Isend(&sr->int0,1,MPIU_REAL,ctx->subc->color-sr->dir,0,ctx->commrank,&req)); } } if ((sr->dir>0 && ctx->subc->colornpart-1)||(sr->dir<0 && ctx->subc->color>0)) { @@ -440,8 +440,8 @@ PetscErrorCode EPSSetUp_KrylovSchur_Slice(EPS eps) PetscCheck(zeros==0,((PetscObject)eps)->comm,PETSC_ERR_USER,"Found singular matrix for the transformed problem in an interval endpoint defined by user"); if (!rank && sr->inertia0==-1) { sr->inertia0 = sr->inertia1; sr->int0 = sr->int1; - PetscCallMPI(MPI_Isend(&(sr->inertia0),1,MPIU_INT,ctx->subc->color-sr->dir,0,ctx->commrank,&req)); - PetscCallMPI(MPI_Isend(&(sr->int0),1,MPIU_REAL,ctx->subc->color-sr->dir,0,ctx->commrank,&req)); + PetscCallMPI(MPI_Isend(&sr->inertia0,1,MPIU_INT,ctx->subc->color-sr->dir,0,ctx->commrank,&req)); + PetscCallMPI(MPI_Isend(&sr->int0,1,MPIU_REAL,ctx->subc->color-sr->dir,0,ctx->commrank,&req)); } if (sr->hasEnd) { sr->dir = -sr->dir; r = sr->int0; sr->int0 = sr->int1; sr->int1 = r; @@ -912,8 +912,8 @@ static PetscErrorCode EPSKrylovSchur_Slice(EPS eps) 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 ((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 { @@ -986,7 +986,7 @@ static PetscErrorCode EPSKrylovSchur_Slice(EPS eps) } /* Check for completion */ for (i=0;i< eps->nconv; i++) { - if ((sr->dir)*PetscRealPart(eps->eigr[i])>0) sPres->nconv[1]++; + if (sr->dir*PetscRealPart(eps->eigr[i])>0) sPres->nconv[1]++; else sPres->nconv[0]++; } sPres->comp[0] = PetscNot(count0 < sPres->nsch[0]); @@ -1019,7 +1019,7 @@ static PetscErrorCode EPSGetNewShiftValue(EPS eps,PetscInt side,PetscReal *newS) 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); + *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) */ PetscCheck(sr->hasEnd || sr->nleap<=5,PetscObjectComm((PetscObject)eps),PETSC_ERR_PLIB,"Unable to compute the wanted eigenvalues with open interval"); @@ -1029,7 +1029,7 @@ static PetscErrorCode EPSGetNewShiftValue(EPS eps,PetscInt side,PetscReal *newS) 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++; + if (sr->dir*(lambda - sPres->value) <0) idxP++; else break; } /* Avoiding subtraction of eigenvalues (might be the same).*/ @@ -1038,7 +1038,7 @@ static PetscErrorCode EPSGetNewShiftValue(EPS eps,PetscInt side,PetscReal *newS) } 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; + *newS = sPres->value + (sr->dir*d_prev*eps->nev)/2; } } else { /* Accepted values found */ sr->nleap = 0; @@ -1051,21 +1051,21 @@ static PetscErrorCode EPSGetNewShiftValue(EPS eps,PetscInt side,PetscReal *newS) 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)) { + 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; + 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; + *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; + if (sr->dir*(sr->int1 - *newS) < 0) *newS = sr->int1; }/* of neighb[side]==null */ PetscFunctionReturn(PETSC_SUCCESS); } @@ -1116,7 +1116,7 @@ static PetscErrorCode EPSStoreEigenpairs(EPS eps) 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 (sr->dir*(lambda - sPres->ext[0]) > 0 && (sr->dir)*(sPres->ext[1] - lambda) > 0) {/* Valid value */ PetscCheck(countnumEigs,PetscObjectComm((PetscObject)eps),PETSC_ERR_PLIB,"Unexpected error in Spectrum Slicing"); sr->eigr[count] = lambda; sr->errest[count] = err; @@ -1168,8 +1168,8 @@ static PetscErrorCode EPSLookForDeflation(EPS eps) 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++; + if (sr->dir*(val - sPres->ext[1]) < 0) { + if (sr->dir*(val - sPres->value) < 0) count0++; else count1++; } else break; } diff --git a/src/eps/impls/krylov/lanczos/lanczos.c b/src/eps/impls/krylov/lanczos/lanczos.c index e85b64bfa..9d67c40d3 100644 --- a/src/eps/impls/krylov/lanczos/lanczos.c +++ b/src/eps/impls/krylov/lanczos/lanczos.c @@ -50,7 +50,7 @@ static PetscErrorCode EPSSetUp_Lanczos(EPS eps) EPSCheckUnsupported(eps,EPS_FEATURE_ARBITRARY | EPS_FEATURE_REGION | EPS_FEATURE_EXTRACTION); EPSCheckIgnored(eps,EPS_FEATURE_BALANCE); - PetscCheck(lanczos->reorthog!=(EPSLanczosReorthogType)-1,PetscObjectComm((PetscObject)eps),PETSC_ERR_USER_INPUT,"You should explicitly provide the reorthogonalization type, e.g., -eps_lanczos_reorthog local\n ... Note that the EPSLANCZOS solver is *NOT RECOMMENDED* for general use, because it uses\n ... explicit restart which typically has slow convergence. The recommended solver is\n ... EPSKRYLOVSCHUR (the default), which implements Lanczos with thick restart in the\n ... case of symmetric/Hermitian problems"); + PetscCheck(lanczos->reorthog!=(EPSLanczosReorthogType)-1,PetscObjectComm((PetscObject)eps),PETSC_ERR_USER_INPUT,"You should explicitly provide the reorthogonalization type, e.g., -eps_lanczos_reorthog local. Note that the EPSLANCZOS solver is *NOT RECOMMENDED* for general use, because it uses explicit restart which typically has slow convergence. The recommended solver is EPSKRYLOVSCHUR (the default), which implements Lanczos with thick restart in the case of symmetric/Hermitian problems"); PetscCall(EPSAllocateSolution(eps,1)); PetscCall(EPS_SetInnerProduct(eps)); diff --git a/src/eps/impls/power/power.c b/src/eps/impls/power/power.c index 51922df6b..c0645f364 100644 --- a/src/eps/impls/power/power.c +++ b/src/eps/impls/power/power.c @@ -117,7 +117,7 @@ static PetscErrorCode EPSSetUp_Power(EPS eps) /* For nonlinear solver (Newton), we should scale the initial vector back. The initial vector will be scaled in EPSSetUp. */ - if (eps->IS) PetscCall(VecNorm((eps->IS)[0],NORM_2,&power->norm0)); + if (eps->IS) PetscCall(VecNorm(eps->IS[0],NORM_2,&power->norm0)); PetscCall(EPSGetOperators(eps,&A,&B)); diff --git a/src/eps/interface/epsbasic.c b/src/eps/interface/epsbasic.c index cdee56a1e..705311d41 100644 --- a/src/eps/interface/epsbasic.c +++ b/src/eps/interface/epsbasic.c @@ -333,7 +333,7 @@ PetscErrorCode EPSDestroy(EPS *eps) PetscFunctionBegin; if (!*eps) PetscFunctionReturn(PETSC_SUCCESS); PetscValidHeaderSpecific(*eps,EPS_CLASSID,1); - if (--((PetscObject)(*eps))->refct > 0) { *eps = NULL; PetscFunctionReturn(PETSC_SUCCESS); } + if (--((PetscObject)*eps)->refct > 0) { *eps = NULL; PetscFunctionReturn(PETSC_SUCCESS); } PetscCall(EPSReset(*eps)); PetscTryTypeMethod(*eps,destroy); if ((*eps)->eigr) PetscCall(PetscFree4((*eps)->eigr,(*eps)->eigi,(*eps)->errest,(*eps)->perm)); diff --git a/src/eps/interface/epssetup.c b/src/eps/interface/epssetup.c index a3bf1317c..e8b9b39dd 100644 --- a/src/eps/interface/epssetup.c +++ b/src/eps/interface/epssetup.c @@ -704,7 +704,7 @@ PetscErrorCode EPSAllocateSolution(EPS eps,PetscInt extra) /* allocate V */ if (!eps->V) PetscCall(EPSGetBV(eps,&eps->V)); if (!oldsize) { - if (!((PetscObject)(eps->V))->type_name) PetscCall(BVSetType(eps->V,BVMAT)); + if (!((PetscObject)eps->V)->type_name) PetscCall(BVSetType(eps->V,BVMAT)); PetscCall(STMatCreateVecsEmpty(eps->st,&t,NULL)); PetscCall(BVSetSizesFromVec(eps->V,t,requested)); PetscCall(VecDestroy(&t)); diff --git a/src/eps/interface/epssolve.c b/src/eps/interface/epssolve.c index ef2d88d77..e89806c45 100644 --- a/src/eps/interface/epssolve.c +++ b/src/eps/interface/epssolve.c @@ -54,7 +54,7 @@ static PetscErrorCode EPSComputeValues(EPS eps) if (B) { PetscCall(DSGetMat(eps->ds,DS_MAT_B,&G)); PetscCall(BVMatProject(eps->V,B,eps->V,G)); - PetscCall(DSRestoreMat(eps->ds,DS_MAT_A,&G)); + PetscCall(DSRestoreMat(eps->ds,DS_MAT_B,&G)); } PetscCall(DSSolve(eps->ds,eps->eigr,eps->eigi)); PetscCall(DSSort(eps->ds,eps->eigr,eps->eigi,NULL,NULL,NULL)); @@ -187,13 +187,13 @@ PetscErrorCode EPSSolve(EPS eps) PetscCall(EPSValuesViewFromOptions(eps)); PetscCall(EPSVectorsViewFromOptions(eps)); - PetscCall(PetscOptionsHasName(NULL,((PetscObject)eps)->prefix,"-eps_view_mat0",&hasname)); + PetscCall(PetscOptionsHasName(((PetscObject)eps)->options,((PetscObject)eps)->prefix,"-eps_view_mat0",&hasname)); if (hasname) { PetscCall(EPSGetOperators(eps,&A,NULL)); PetscCall(MatViewFromOptions(A,(PetscObject)eps,"-eps_view_mat0")); } if (eps->isgeneralized) { - PetscCall(PetscOptionsHasName(NULL,((PetscObject)eps)->prefix,"-eps_view_mat1",&hasname)); + PetscCall(PetscOptionsHasName(((PetscObject)eps)->options,((PetscObject)eps)->prefix,"-eps_view_mat1",&hasname)); if (hasname) { PetscCall(EPSGetOperators(eps,NULL,&B)); PetscCall(MatViewFromOptions(B,(PetscObject)eps,"-eps_view_mat1")); diff --git a/src/eps/tests/output/test43_1.out b/src/eps/tests/output/test43_1.out index 4f6961c7a..590384669 100644 --- a/src/eps/tests/output/test43_1.out +++ b/src/eps/tests/output/test43_1.out @@ -4,7 +4,7 @@ KSP Object: 4 MPI processes HPDDM type: gmres precision: DOUBLE maximum iterations=10, initial guess is zero - tolerances: relative=0.001, absolute=1e-50, divergence=10000. + tolerances: relative=0.001, absolute=1e-50, divergence=10000. left preconditioning using PRECONDITIONED norm type for convergence test PC Object: 4 MPI processes @@ -17,7 +17,7 @@ PC Object: 4 MPI processes KSP Object: (pc_hpddm_levels_1_) 4 MPI processes type: preonly maximum iterations=10000, initial guess is zero - tolerances: relative=1e-05, absolute=1e-50, divergence=10000. + tolerances: relative=1e-05, absolute=1e-50, divergence=10000. left preconditioning using NONE norm type for convergence test PC Object: (pc_hpddm_levels_1_) 4 MPI processes @@ -36,7 +36,7 @@ PC Object: 4 MPI processes KSP Object: (pc_hpddm_levels_1_sub_) 1 MPI process type: preonly maximum iterations=10000, initial guess is zero - tolerances: relative=1e-05, absolute=1e-50, divergence=10000. + tolerances: relative=1e-05, absolute=1e-50, divergence=10000. left preconditioning using NONE norm type for convergence test PC Object: (pc_hpddm_levels_1_sub_) 1 MPI process @@ -59,7 +59,7 @@ PC Object: 4 MPI processes KSP Object: (pc_hpddm_coarse_) 1 MPI process type: preonly maximum iterations=10000, initial guess is zero - tolerances: relative=1e-05, absolute=1e-50, divergence=10000. + tolerances: relative=1e-05, absolute=1e-50, divergence=10000. left preconditioning using NONE norm type for convergence test PC Object: (pc_hpddm_coarse_) 1 MPI process diff --git a/src/eps/tests/test1.c b/src/eps/tests/test1.c index cb2cadea4..53bfcc563 100644 --- a/src/eps/tests/test1.c +++ b/src/eps/tests/test1.c @@ -39,12 +39,10 @@ int main(int argc,char **argv) PetscCall(MatCreate(PETSC_COMM_WORLD,&A)); PetscCall(MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N)); PetscCall(MatSetFromOptions(A)); - PetscCall(MatSetUp(A)); PetscCall(MatCreate(PETSC_COMM_WORLD,&B)); PetscCall(MatSetSizes(B,PETSC_DECIDE,PETSC_DECIDE,N,N)); PetscCall(MatSetFromOptions(B)); - PetscCall(MatSetUp(B)); PetscCall(MatGetOwnershipRange(A,&Istart,&Iend)); for (II=Istart;II0) PetscCall(MatSetValue(A,i,i-1,-1.0,INSERT_VALUES)); diff --git a/src/eps/tests/test21.c b/src/eps/tests/test21.c index 03846cc5a..380ce19e2 100644 --- a/src/eps/tests/test21.c +++ b/src/eps/tests/test21.c @@ -50,7 +50,6 @@ int main(int argc,char **argv) PetscCall(MatCreate(PETSC_COMM_WORLD,&A)); PetscCall(MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N)); PetscCall(MatSetFromOptions(A)); - PetscCall(MatSetUp(A)); PetscCall(MatMarkovModel(m,A)); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/eps/tests/test22.c b/src/eps/tests/test22.c index 7119f362e..2f3b2ff6b 100644 --- a/src/eps/tests/test22.c +++ b/src/eps/tests/test22.c @@ -80,7 +80,6 @@ int main(int argc,char **argv) PetscCall(MatCreate(PETSC_COMM_WORLD,&ctx->T)); PetscCall(MatSetSizes(ctx->T,PETSC_DECIDE,PETSC_DECIDE,N,N)); PetscCall(MatSetFromOptions(ctx->T)); - PetscCall(MatSetUp(ctx->T)); PetscCall(MatGetOwnershipRange(ctx->T,&Istart,&Iend)); for (i=Istart;i0) PetscCall(MatSetValue(ctx->T,i,i-1,1.0,INSERT_VALUES)); diff --git a/src/eps/tests/test23.c b/src/eps/tests/test23.c index a01036744..9a5f276f1 100644 --- a/src/eps/tests/test23.c +++ b/src/eps/tests/test23.c @@ -29,7 +29,6 @@ int main(int argc,char **argv) PetscCall(MatCreate(PETSC_COMM_WORLD,&A)); PetscCall(MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n)); PetscCall(MatSetFromOptions(A)); - PetscCall(MatSetUp(A)); PetscCall(MatGetOwnershipRange(A,&Istart,&Iend)); for (i=Istart;i0) PetscCall(MatSetValue(T1,i,i-1,1.0,INSERT_VALUES)); diff --git a/src/eps/tests/test38.c b/src/eps/tests/test38.c index d983ccecb..967d48e35 100644 --- a/src/eps/tests/test38.c +++ b/src/eps/tests/test38.c @@ -41,7 +41,6 @@ int main(int argc,char **argv) PetscCall(MatCreate(PETSC_COMM_WORLD,&A)); PetscCall(MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N)); PetscCall(MatSetFromOptions(A)); - PetscCall(MatSetUp(A)); PetscCall(MatGetOwnershipRange(A,&Istart,&Iend)); for (II=Istart;IIT)); PetscCall(MatSetSizes(ctx->T,PETSC_DECIDE,PETSC_DECIDE,N,N)); PetscCall(MatSetFromOptions(ctx->T)); - PetscCall(MatSetUp(ctx->T)); PetscCall(MatGetOwnershipRange(ctx->T,&Istart,&Iend)); for (i=Istart;iT)); PetscCall(MatSetSizes(ctx->T,PETSC_DECIDE,PETSC_DECIDE,N,N)); PetscCall(MatSetFromOptions(ctx->T)); - PetscCall(MatSetUp(ctx->T)); PetscCall(MatGetOwnershipRange(ctx->T,&Istart,&Iend)); for (i=Istart;irefct > 0) { *lme = NULL; PetscFunctionReturn(PETSC_SUCCESS); } + if (--((PetscObject)*lme)->refct > 0) { *lme = NULL; PetscFunctionReturn(PETSC_SUCCESS); } PetscCall(LMEReset(*lme)); PetscTryTypeMethod(*lme,destroy); PetscCall(LMEMonitorCancel(*lme)); diff --git a/src/lme/interface/lmesetup.c b/src/lme/interface/lmesetup.c index ac6643183..362bc816c 100644 --- a/src/lme/interface/lmesetup.c +++ b/src/lme/interface/lmesetup.c @@ -378,7 +378,7 @@ PetscErrorCode LMEAllocateSolution(LME lme,PetscInt extra) /* allocate basis vectors */ if (!lme->V) PetscCall(LMEGetBV(lme,&lme->V)); if (!oldsize) { - if (!((PetscObject)(lme->V))->type_name) PetscCall(BVSetType(lme->V,BVMAT)); + if (!((PetscObject)lme->V)->type_name) PetscCall(BVSetType(lme->V,BVMAT)); PetscCall(MatCreateVecsEmpty(lme->A,&t,NULL)); PetscCall(BVSetSizesFromVec(lme->V,t,requested)); PetscCall(VecDestroy(&t)); diff --git a/src/lme/tests/test1.c b/src/lme/tests/test1.c index 33fae52dc..5a04896db 100644 --- a/src/lme/tests/test1.c +++ b/src/lme/tests/test1.c @@ -46,7 +46,6 @@ int main(int argc,char **argv) PetscCall(MatCreate(PETSC_COMM_WORLD,&A)); PetscCall(MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N)); PetscCall(MatSetFromOptions(A)); - PetscCall(MatSetUp(A)); PetscCall(MatGetOwnershipRange(A,&Istart,&Iend)); for (II=Istart;IIrefct > 0) { *mfn = NULL; PetscFunctionReturn(PETSC_SUCCESS); } + if (--((PetscObject)*mfn)->refct > 0) { *mfn = NULL; PetscFunctionReturn(PETSC_SUCCESS); } PetscCall(MFNReset(*mfn)); PetscTryTypeMethod(*mfn,destroy); PetscCall(FNDestroy(&(*mfn)->fn)); diff --git a/src/mfn/interface/mfnsetup.c b/src/mfn/interface/mfnsetup.c index 07b764a06..565d5439f 100644 --- a/src/mfn/interface/mfnsetup.c +++ b/src/mfn/interface/mfnsetup.c @@ -158,7 +158,7 @@ PetscErrorCode MFNAllocateSolution(MFN mfn,PetscInt extra) /* allocate basis vectors */ if (!mfn->V) PetscCall(MFNGetBV(mfn,&mfn->V)); if (!oldsize) { - if (!((PetscObject)(mfn->V))->type_name) PetscCall(BVSetType(mfn->V,BVMAT)); + if (!((PetscObject)mfn->V)->type_name) PetscCall(BVSetType(mfn->V,BVMAT)); PetscCall(MatCreateVecsEmpty(mfn->A,&t,NULL)); PetscCall(BVSetSizesFromVec(mfn->V,t,requested)); PetscCall(VecDestroy(&t)); diff --git a/src/mfn/tests/output/test5_1.out b/src/mfn/tests/output/test5_1.out new file mode 100644 index 000000000..36fdd4d2a --- /dev/null +++ b/src/mfn/tests/output/test5_1.out @@ -0,0 +1,21 @@ + +Matrix exponential y=exp(t*A)*e, of the 2-D Laplacian, N=625 (25x25 grid) + +MFN Object: 1 MPI process + type: expokit + number of column vectors (ncv): 24 + maximum number of iterations: 1000 + tolerance: 1e-05 +FN Object: 1 MPI process + type: exp + exponential: exp(x) + computing matrix functions with: scaling & squaring, [m/m] Pade approximant (Higham) +BV Object: 1 MPI process + type: mat + 0 columns of global length -1 + vector orthogonalization method: classical Gram-Schmidt + orthogonalization refinement: if needed (eta: 0.7071) + block orthogonalization method: GS + doing matmult as a single matrix-matrix product + Computed vector at time t=0.3 has norm 26.7835 + diff --git a/src/mfn/tests/test1.c b/src/mfn/tests/test1.c index 7197cb6da..d3b94e41a 100644 --- a/src/mfn/tests/test1.c +++ b/src/mfn/tests/test1.c @@ -53,8 +53,7 @@ int main(int argc,char **argv) PetscCall(PetscViewerDestroy(&viewer)); /* set v = ones(n,1) */ - PetscCall(MatCreateVecs(A,NULL,&y)); - PetscCall(MatCreateVecs(A,NULL,&v)); + PetscCall(MatCreateVecs(A,&v,&y)); PetscCall(VecSet(v,1.0)); /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/mfn/tests/test2.c b/src/mfn/tests/test2.c index 222250e0d..f008d31c0 100644 --- a/src/mfn/tests/test2.c +++ b/src/mfn/tests/test2.c @@ -44,7 +44,6 @@ int main(int argc,char **argv) PetscCall(MatCreate(PETSC_COMM_WORLD,&A)); PetscCall(MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N)); PetscCall(MatSetFromOptions(A)); - PetscCall(MatSetUp(A)); PetscCall(MatGetOwnershipRange(A,&Istart,&Iend)); for (II=Istart;II + +int main(int argc,char **argv) +{ + Mat A; /* problem matrix */ + MFN mfn; + FN f; + PetscReal norm; + PetscScalar t=0.3; + PetscInt N,n=25,m,Istart,Iend,II,i,j; + PetscBool flag; + Vec v,y; + + PetscFunctionBeginUser; + PetscCall(SlepcInitialize(&argc,&argv,(char*)0,help)); + + PetscCall(PetscOptionsGetInt(NULL,NULL,"-n",&n,NULL)); + PetscCall(PetscOptionsGetInt(NULL,NULL,"-m",&m,&flag)); + if (!flag) m=n; + N = n*m; + PetscCall(PetscOptionsGetScalar(NULL,NULL,"-t",&t,NULL)); + PetscCall(PetscPrintf(PETSC_COMM_WORLD,"\nMatrix exponential y=exp(t*A)*e, of the 2-D Laplacian, N=%" PetscInt_FMT " (%" PetscInt_FMT "x%" PetscInt_FMT " grid)\n\n",N,n,m)); + + /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + Build the 2-D Laplacian + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ + + PetscCall(MatCreate(PETSC_COMM_WORLD,&A)); + PetscCall(MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N)); + PetscCall(MatSetFromOptions(A)); + + PetscCall(MatGetOwnershipRange(A,&Istart,&Iend)); + for (II=Istart;II0) PetscCall(MatSetValue(A,II,II-n,-1.0,INSERT_VALUES)); + if (i0) PetscCall(MatSetValue(A,II,II-1,-1.0,INSERT_VALUES)); + if (j0) PetscCall(MatSetValue(L,i,i-1,c,INSERT_VALUES)); diff --git a/src/nep/impls/nleigs/nleigs-fullb.c b/src/nep/impls/nleigs/nleigs-fullb.c index 77dab9e1c..d24798a9d 100644 --- a/src/nep/impls/nleigs/nleigs-fullb.c +++ b/src/nep/impls/nleigs/nleigs-fullb.c @@ -246,7 +246,7 @@ PetscErrorCode NEPSetUp_NLEIGS_FullBasis(NEP nep) PetscCall(EPSGetST(ctx->eps,&st)); PetscCall(EPSSetTarget(ctx->eps,nep->target)); PetscCall(STSetDefaultShift(st,nep->target)); - if (!((PetscObject)(ctx->eps))->type_name) PetscCall(EPSSetType(ctx->eps,EPSKRYLOVSCHUR)); + if (!((PetscObject)ctx->eps)->type_name) PetscCall(EPSSetType(ctx->eps,EPSKRYLOVSCHUR)); else { PetscCall(PetscObjectTypeCompare((PetscObject)ctx->eps,EPSKRYLOVSCHUR,&ks)); PetscCheck(ks,PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"Full-basis option only implemented for Krylov-Schur"); diff --git a/src/nep/impls/nleigs/nleigs.c b/src/nep/impls/nleigs/nleigs.c index c59b763a9..fdb8f55b8 100644 --- a/src/nep/impls/nleigs/nleigs.c +++ b/src/nep/impls/nleigs/nleigs.c @@ -372,7 +372,7 @@ static PetscErrorCode NEPNLEIGSLejaBagbyPoints(NEP nep) } #endif /* Discretize the singularity region */ - if (ctx->computesingularities) PetscCall((ctx->computesingularities)(nep,&ndptx,dxi,ctx->singularitiesctx)); + if (ctx->computesingularities) PetscCall(ctx->computesingularities(nep,&ndptx,dxi,ctx->singularitiesctx)); else { if (nep->problem_type==NEP_RATIONAL) { PetscCall(NEPNLEIGSRationalSingularities(nep,&ndptx,dxi,&rational)); diff --git a/src/nep/interface/nepbasic.c b/src/nep/interface/nepbasic.c index aa86eabd2..0085050e8 100644 --- a/src/nep/interface/nepbasic.c +++ b/src/nep/interface/nepbasic.c @@ -345,7 +345,7 @@ PetscErrorCode NEPDestroy(NEP *nep) PetscFunctionBegin; if (!*nep) PetscFunctionReturn(PETSC_SUCCESS); PetscValidHeaderSpecific(*nep,NEP_CLASSID,1); - if (--((PetscObject)(*nep))->refct > 0) { *nep = NULL; PetscFunctionReturn(PETSC_SUCCESS); } + if (--((PetscObject)*nep)->refct > 0) { *nep = NULL; PetscFunctionReturn(PETSC_SUCCESS); } PetscCall(NEPReset(*nep)); PetscTryTypeMethod(*nep,destroy); if ((*nep)->eigr) PetscCall(PetscFree4((*nep)->eigr,(*nep)->eigi,(*nep)->errest,(*nep)->perm)); diff --git a/src/nep/interface/neprefine.c b/src/nep/interface/neprefine.c index e234cb957..4427bd8a9 100644 --- a/src/nep/interface/neprefine.c +++ b/src/nep/interface/neprefine.c @@ -182,7 +182,7 @@ static PetscErrorCode NEPSimpleNRefScatterEigenvector(NEP nep,NEPSimpNRefctx *ct static PetscErrorCode NEPSimpleNRefSetUpSystem(NEP nep,NEPSimpNRefctx *ctx,Mat *A,PetscInt idx,Mat *Mt,Mat *T,Mat *P,PetscBool ini,Vec t,Vec v) { PetscInt i,st,ml,m0,n0,m1,mg; - PetscInt *dnz,*onz,ncols,*cols2=NULL,*nnz,nt=nep->nt; + PetscInt ncols,*cols2=NULL,nt=nep->nt; PetscScalar zero=0.0,*coeffs,*coeffs2; PetscMPIInt rank,size; MPI_Comm comm; @@ -239,35 +239,6 @@ static PetscErrorCode NEPSimpleNRefSetUpSystem(NEP nep,NEPSimpNRefctx *ctx,Mat * if (rank==size-1) ml++; PetscCall(MatSetSizes(*T,ml,ml,mg+1,mg+1)); PetscCall(MatSetFromOptions(*T)); - PetscCall(MatSetUp(*T)); - /* Preallocate M */ - if (size>1) { - MatPreallocateBegin(comm,ml,ml,dnz,onz); - for (i=m0;iV) PetscCall(NEPGetBV(nep,&nep->V)); if (!oldsize) { - if (!((PetscObject)(nep->V))->type_name) PetscCall(BVSetType(nep->V,BVMAT)); + if (!((PetscObject)nep->V)->type_name) PetscCall(BVSetType(nep->V,BVMAT)); if (nep->fui==NEP_USER_INTERFACE_SPLIT) T = nep->A[0]; else PetscCall(NEPGetFunction(nep,&T,NULL,NULL,NULL)); PetscCall(MatCreateVecsEmpty(T,&t,NULL)); diff --git a/src/nep/tests/output/test2_1.out b/src/nep/tests/output/test2_1.out index 9ba8c83c9..5c5bcd6cf 100644 --- a/src/nep/tests/output/test2_1.out +++ b/src/nep/tests/output/test2_1.out @@ -39,8 +39,84 @@ DS Object: 1 MPI process type not yet set RG Object: 1 MPI process type: interval - region: [-inf.,inf.]x[-inf.,inf.] + region: [-inf.,inf.]x[-inf.,inf.] +NEP Object: 1 MPI process + type: rii + maximum number of inner iterations: 10 + updating the preconditioner every 1 iterations + KSP Object: (nep_rii_) 1 MPI process + type: gmres + restart=30, using Classical (unmodified) Gram-Schmidt Orthogonalization with no iterative refinement + maximum iterations=10000, initial guess is zero + left preconditioning + using PRECONDITIONED norm type for convergence test + PC Object: (nep_rii_) 1 MPI process + type: ilu + out-of-place factorization + 0 levels of fill + matrix ordering: natural + factor fill ratio given 1., needed 1. + Factored matrix follows: + Mat Object: (nep_rii_) 1 MPI process + type: seqaij + rows=20, cols=20 + package used to perform factorization: petsc + total: nonzeros=20, allocated nonzeros=20 + not using I-node routines + linear system matrix = precond matrix: + Mat Object: (nep_rii_) 1 MPI process + type: seqaij + rows=20, cols=20 + total: nonzeros=20, allocated nonzeros=20 + total number of mallocs used during MatSetValues calls=0 + not using I-node routines + problem type: rational eigenvalue problem + nonlinear operator in split form + number of terms: 3 + nonzero pattern of the matrices: SAME + selected portion of the spectrum: closest to target: 1.1 (in magnitude) + number of eigenvalues (nev): 1 + number of column vectors (ncv): 1 + maximum dimension of projected problem (mpd): 1 + maximum number of iterations: 200 + convergence test: absolute + iterative refinement: SIMPLE, with EXPLICIT scheme + refinement stopping criterion: tol=1e-09, its=2 +BV Object: 1 MPI process + type: mat + 1 columns of global length 20 + vector orthogonalization method: classical Gram-Schmidt + orthogonalization refinement: if needed (eta: 0.7071) + block orthogonalization method: GS + doing matmult as a single matrix-matrix product +DS Object: 1 MPI process + type: nhep + KSP Object: (nep_refine_) 1 MPI process + type: gmres + restart=30, using Classical (unmodified) Gram-Schmidt Orthogonalization with no iterative refinement + maximum iterations=10000, initial guess is zero + left preconditioning + using PRECONDITIONED norm type for convergence test + PC Object: (nep_refine_) 1 MPI process + type: ilu + out-of-place factorization + 0 levels of fill + matrix ordering: natural + factor fill ratio given 1., needed 1. + Factored matrix follows: + Mat Object: (nep_refine_) 1 MPI process + type: seqaij + rows=21, cols=21 + package used to perform factorization: petsc + total: nonzeros=61, allocated nonzeros=61 + not using I-node routines + linear system matrix = precond matrix: + Mat Object: (nep_refine_) 1 MPI process + type: seqaij + rows=21, cols=21 + total: nonzeros=61, allocated nonzeros=61 + total number of mallocs used during MatSetValues calls=0 + not using I-node routines Finished - converged reason = 1 - All requested eigenvalues computed up to the required tolerance: 1.00000 diff --git a/src/nep/tests/test1.c b/src/nep/tests/test1.c index 0a7110f71..0757b132d 100644 --- a/src/nep/tests/test1.c +++ b/src/nep/tests/test1.c @@ -66,7 +66,6 @@ int main(int argc,char **argv) PetscCall(MatSetFromOptions(F)); PetscCall(MatSeqAIJSetPreallocation(F,3,NULL)); PetscCall(MatMPIAIJSetPreallocation(F,3,NULL,1,NULL)); - PetscCall(MatSetUp(F)); PetscCall(NEPSetFunction(nep,F,F,FormFunction,&ctx)); PetscCall(MatCreate(PETSC_COMM_WORLD,&J)); @@ -74,7 +73,6 @@ int main(int argc,char **argv) PetscCall(MatSetFromOptions(J)); PetscCall(MatSeqAIJSetPreallocation(J,3,NULL)); PetscCall(MatMPIAIJSetPreallocation(F,3,NULL,1,NULL)); - PetscCall(MatSetUp(J)); PetscCall(NEPSetJacobian(nep,J,FormJacobian,&ctx)); PetscCall(NEPSetFromOptions(nep)); diff --git a/src/nep/tests/test10.c b/src/nep/tests/test10.c index d60940e7d..826a2f8c1 100644 --- a/src/nep/tests/test10.c +++ b/src/nep/tests/test10.c @@ -46,7 +46,6 @@ PetscErrorCode BuildSplitMatrices(PetscInt n,PetscReal a,Mat *Id,Mat *A,Mat *B) PetscCall(MatCreate(PETSC_COMM_WORLD,A)); PetscCall(MatSetSizes(*A,PETSC_DECIDE,PETSC_DECIDE,n,n)); PetscCall(MatSetFromOptions(*A)); - PetscCall(MatSetUp(*A)); PetscCall(MatGetOwnershipRange(*A,&Istart,&Iend)); for (i=Istart;i0) PetscCall(MatSetValue(*A,i,i-1,1.0/(h*h),INSERT_VALUES)); @@ -61,7 +60,6 @@ PetscErrorCode BuildSplitMatrices(PetscInt n,PetscReal a,Mat *Id,Mat *A,Mat *B) PetscCall(MatCreate(PETSC_COMM_WORLD,B)); PetscCall(MatSetSizes(*B,PETSC_DECIDE,PETSC_DECIDE,n,n)); PetscCall(MatSetFromOptions(*B)); - PetscCall(MatSetUp(*B)); PetscCall(MatGetOwnershipRange(*B,&Istart,&Iend)); for (i=Istart;i0) PetscCall(MatSetValue(A,i,i-1,1.0/(h*h),INSERT_VALUES)); @@ -82,7 +81,6 @@ int main(int argc,char **argv) PetscCall(MatCreate(PETSC_COMM_WORLD,&B)); PetscCall(MatSetSizes(B,PETSC_DECIDE,PETSC_DECIDE,n,n)); PetscCall(MatSetFromOptions(B)); - PetscCall(MatSetUp(B)); PetscCall(MatGetOwnershipRange(B,&Istart,&Iend)); for (i=Istart;i0) PetscCall(MatSetValue(A[0],i,i-1,1.0,INSERT_VALUES)); diff --git a/src/nep/tests/test13.c b/src/nep/tests/test13.c index 5da7b9dbb..8ddb6e363 100644 --- a/src/nep/tests/test13.c +++ b/src/nep/tests/test13.c @@ -66,7 +66,6 @@ int main(int argc,char **argv) PetscCall(MatCreate(PETSC_COMM_WORLD,&A)); PetscCall(MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n)); PetscCall(MatSetFromOptions(A)); - PetscCall(MatSetUp(A)); PetscCall(MatGetOwnershipRange(A,&Istart,&Iend)); for (i=Istart;i0) PetscCall(MatSetValue(A,i,i-1,1.0/(h*h),INSERT_VALUES)); @@ -81,7 +80,6 @@ int main(int argc,char **argv) PetscCall(MatCreate(PETSC_COMM_WORLD,&B)); PetscCall(MatSetSizes(B,PETSC_DECIDE,PETSC_DECIDE,n,n)); PetscCall(MatSetFromOptions(B)); - PetscCall(MatSetUp(B)); PetscCall(MatGetOwnershipRange(B,&Istart,&Iend)); for (i=Istart;i0) PetscCall(MatSetValue(A[0],i,i-1,1.0,INSERT_VALUES)); diff --git a/src/nep/tests/test15.c b/src/nep/tests/test15.c index 3b67620fa..6a6855036 100644 --- a/src/nep/tests/test15.c +++ b/src/nep/tests/test15.c @@ -79,7 +79,6 @@ int main(int argc,char **argv) PetscCall(MatCreate(PETSC_COMM_WORLD,&A)); PetscCall(MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n)); PetscCall(MatSetFromOptions(A)); - PetscCall(MatSetUp(A)); PetscCall(MatGetOwnershipRange(A,&Istart,&Iend)); for (i=Istart;i0) PetscCall(MatSetValue(A,i,i-1,1.0/(h*h),INSERT_VALUES)); @@ -94,7 +93,6 @@ int main(int argc,char **argv) PetscCall(MatCreate(PETSC_COMM_WORLD,&B)); PetscCall(MatSetSizes(B,PETSC_DECIDE,PETSC_DECIDE,n,n)); PetscCall(MatSetFromOptions(B)); - PetscCall(MatSetUp(B)); PetscCall(MatGetOwnershipRange(B,&Istart,&Iend)); for (i=Istart;i0) PetscCall(MatSetValue(*A,i,i-1,1.0/(h*h),INSERT_VALUES)); @@ -62,7 +61,6 @@ PetscErrorCode BuildSplitMatrices(PetscInt n,PetscReal a,Mat *Id,Mat *A,Mat *B) PetscCall(MatCreate(PETSC_COMM_WORLD,B)); PetscCall(MatSetSizes(*B,PETSC_DECIDE,PETSC_DECIDE,n,n)); PetscCall(MatSetFromOptions(*B)); - PetscCall(MatSetUp(*B)); PetscCall(MatGetOwnershipRange(*B,&Istart,&Iend)); for (i=Istart;i0) PetscCall(MatSetValue(A,i,i-1,1.0/(h*h),INSERT_VALUES)); @@ -96,7 +95,6 @@ int main(int argc,char **argv) PetscCall(MatCreate(PETSC_COMM_WORLD,&B)); PetscCall(MatSetSizes(B,PETSC_DECIDE,PETSC_DECIDE,n,n)); PetscCall(MatSetFromOptions(B)); - PetscCall(MatSetUp(B)); PetscCall(MatGetOwnershipRange(B,&Istart,&Iend)); for (i=Istart;i0) PetscCall(MatSetValue(A,i,i-1,1.0/(h*h),INSERT_VALUES)); @@ -95,7 +94,6 @@ int main(int argc,char **argv) PetscCall(MatCreate(PETSC_COMM_WORLD,&B)); PetscCall(MatSetSizes(B,PETSC_DECIDE,PETSC_DECIDE,n,n)); PetscCall(MatSetFromOptions(B)); - PetscCall(MatSetUp(B)); PetscCall(MatGetOwnershipRange(B,&Istart,&Iend)); for (i=Istart;i0) PetscCall(MatSetValue(A,i,i-1,1.0/(h*h),INSERT_VALUES)); @@ -90,7 +89,6 @@ int main(int argc,char **argv) PetscCall(MatCreate(PETSC_COMM_WORLD,&B)); PetscCall(MatSetSizes(B,PETSC_DECIDE,PETSC_DECIDE,n,n)); PetscCall(MatSetFromOptions(B)); - PetscCall(MatSetUp(B)); PetscCall(MatGetOwnershipRange(B,&Istart,&Iend)); for (i=Istart;i0) PetscCall(MatSetValue(A[0],i,i-1,1.0,INSERT_VALUES)); @@ -110,7 +109,6 @@ int main(int argc,char **argv) PetscCall(MatSetFromOptions(F)); PetscCall(MatSeqAIJSetPreallocation(F,3,NULL)); PetscCall(MatMPIAIJSetPreallocation(F,3,NULL,1,NULL)); - PetscCall(MatSetUp(F)); PetscCall(NEPSetFunction(nep,F,F,FormFunction,NULL)); PetscCall(MatCreate(PETSC_COMM_WORLD,&J)); @@ -118,7 +116,6 @@ int main(int argc,char **argv) PetscCall(MatSetFromOptions(J)); PetscCall(MatSeqAIJSetPreallocation(J,1,NULL)); PetscCall(MatMPIAIJSetPreallocation(J,1,NULL,1,NULL)); - PetscCall(MatSetUp(J)); PetscCall(NEPSetJacobian(nep,J,FormJacobian,NULL)); } diff --git a/src/nep/tutorials/ex27f.F90 b/src/nep/tutorials/ex27f.F90 index ac4e814b1..a7e1c886a 100644 --- a/src/nep/tutorials/ex27f.F90 +++ b/src/nep/tutorials/ex27f.F90 @@ -95,7 +95,6 @@ PROGRAM main PetscCallA(MatCreate(PETSC_COMM_WORLD,A(1),ierr)) PetscCallA(MatSetSizes(A(1),PETSC_DECIDE,PETSC_DECIDE,n,n,ierr)) PetscCallA(MatSetFromOptions(A(1),ierr)) - PetscCallA(MatSetUp(A(1),ierr)) PetscCallA(MatGetOwnershipRange(A(1),Istart,Iend,ierr)) coeffs = -2.0 do i=Istart,Iend-1 @@ -128,7 +127,6 @@ PROGRAM main PetscCallA(MatSetFromOptions(F,ierr)) PetscCallA(MatSeqAIJSetPreallocation(F,three,PETSC_NULL_INTEGER,ierr)) PetscCallA(MatMPIAIJSetPreallocation(F,three,PETSC_NULL_INTEGER,one,PETSC_NULL_INTEGER,ierr)) - PetscCallA(MatSetUp(F,ierr)) PetscCallA(NEPSetFunction(nep,F,F,FormFunction,PETSC_NULL_INTEGER,ierr)) PetscCallA(MatCreate(PETSC_COMM_WORLD,J,ierr)) @@ -136,7 +134,6 @@ PROGRAM main PetscCallA(MatSetFromOptions(J,ierr)) PetscCallA(MatSeqAIJSetPreallocation(J,one,PETSC_NULL_INTEGER,ierr)) PetscCallA(MatMPIAIJSetPreallocation(J,one,PETSC_NULL_INTEGER,one,PETSC_NULL_INTEGER,ierr)) - PetscCallA(MatSetUp(J,ierr)) PetscCallA(NEPSetJacobian(nep,J,FormJacobian,PETSC_NULL_INTEGER,ierr)) end if diff --git a/src/nep/tutorials/ex42.c b/src/nep/tutorials/ex42.c index 5e16ccff9..b3e004778 100644 --- a/src/nep/tutorials/ex42.c +++ b/src/nep/tutorials/ex42.c @@ -59,7 +59,6 @@ int main(int argc,char **argv) PetscCall(MatCreate(PETSC_COMM_WORLD,&A[i])); PetscCall(MatSetSizes(A[i],PETSC_DECIDE,PETSC_DECIDE,n,n)); PetscCall(MatSetFromOptions(A[i])); - PetscCall(MatSetUp(A[i])); } PetscCall(MatGetOwnershipRange(A[0],&Istart,&Iend)); diff --git a/src/nep/tutorials/nlevp/loaded_string.c b/src/nep/tutorials/nlevp/loaded_string.c index 38083605a..064af481d 100644 --- a/src/nep/tutorials/nlevp/loaded_string.c +++ b/src/nep/tutorials/nlevp/loaded_string.c @@ -57,11 +57,10 @@ int main(int argc,char **argv) PetscCall(MatCreate(PETSC_COMM_WORLD,&A[i])); PetscCall(MatSetSizes(A[i],PETSC_DECIDE,PETSC_DECIDE,n,n)); PetscCall(MatSetFromOptions(A[i])); - PetscCall(MatSetUp(A[i])); } - PetscCall(MatGetOwnershipRange(A[0],&Istart,&Iend)); /* A0 */ + PetscCall(MatGetOwnershipRange(A[0],&Istart,&Iend)); for (i=Istart;i0) PetscCall(MatSetValue(A[0],i,i-1,-1.0*n,INSERT_VALUES)); @@ -69,6 +68,7 @@ int main(int argc,char **argv) } /* A1 */ + PetscCall(MatGetOwnershipRange(A[1],&Istart,&Iend)); for (i=Istart;i0) PetscCall(MatSetValue(A[1],i,i-1,1.0/(6.0*n),INSERT_VALUES)); @@ -76,6 +76,7 @@ int main(int argc,char **argv) } /* A2 */ + PetscCall(MatGetOwnershipRange(A[2],&Istart,&Iend)); if (Istart<=n-1 && n-1V,pjd->ld-1,pjd->N)); PetscCall(BVDuplicateResize(pep->V,pjd->ld-1,pjd->N+1)); pjd->X = pep->V; - PetscCall(PetscCalloc3((pjd->ld)*(pjd->ld),&pjd->XpX,pep->ncv*pep->ncv,&pjd->T,pjd->ld*pjd->ld*pep->nmat,&pjd->Tj)); + PetscCall(PetscCalloc3(pjd->ld*pjd->ld,&pjd->XpX,pep->ncv*pep->ncv,&pjd->T,pjd->ld*pjd->ld*pep->nmat,&pjd->Tj)); } else pjd->V = pep->V; if (pjd->proj==PEP_JD_PROJECTION_HARMONIC) PetscCall(PEPJDDuplicateBasis(pep,&pjd->W)); else pjd->W = pjd->V; @@ -711,7 +711,7 @@ static PetscErrorCode MatMult_PEPJD(Mat P,Vec x,Vec y) PetscFunctionBegin; PetscCallMPI(MPI_Comm_size(PetscObjectComm((PetscObject)P),&np)); PetscCall(MatShellGetContext(P,&matctx)); - pjd = (PEP_JD*)(matctx->pep->data); + pjd = (PEP_JD*)matctx->pep->data; nconv = pjd->nlock; nmat = matctx->pep->nmat; ncv = matctx->pep->ncv; @@ -835,7 +835,7 @@ static PetscErrorCode MatCreateVecs_PEPJD(Mat A,Vec *right,Vec *left) PetscFunctionBegin; PetscCall(MatShellGetContext(A,&matctx)); - pjd = (PEP_JD*)(matctx->pep->data); + pjd = (PEP_JD*)matctx->pep->data; #if !defined (PETSC_USE_COMPLEX) kspsf = 2; #endif @@ -1101,9 +1101,9 @@ static PetscErrorCode PEPJDLockConverged(PEP pep,PetscInt *nv,PetscInt sz) PetscCall(BVSetActiveColumns(pjd->AX[j],0,pjd->nlock-i+1)); } PetscCall(BVRestoreColumn(pjd->X,pjd->nlock-i,&x)); - PetscCall(BVDotColumn(pjd->X,(pjd->nlock-i),pjd->XpX+(pjd->nlock-i)*(pjd->ld))); + PetscCall(BVDotColumn(pjd->X,(pjd->nlock-i),pjd->XpX+(pjd->nlock-i)*pjd->ld)); pjd->XpX[(pjd->nlock-i)*(1+pjd->ld)] = 1.0; - for (j=0;jnlock-i;j++) pjd->XpX[j*(pjd->ld)+pjd->nlock-i] = PetscConj(pjd->XpX[(pjd->nlock-i)*(pjd->ld)+j]); + for (j=0;jnlock-i;j++) pjd->XpX[j*pjd->ld+pjd->nlock-i] = PetscConj(pjd->XpX[(pjd->nlock-i)*pjd->ld+j]); } /* minimality index */ diff --git a/src/pep/impls/krylov/qarnoldi/qarnoldi.c b/src/pep/impls/krylov/qarnoldi/qarnoldi.c index 0365218f2..eed522a86 100644 --- a/src/pep/impls/krylov/qarnoldi/qarnoldi.c +++ b/src/pep/impls/krylov/qarnoldi/qarnoldi.c @@ -60,7 +60,6 @@ static PetscErrorCode PEPSetUp_QArnoldi(PEP pep) PetscCall(DSSetType(pep->ds,DSNHEP)); PetscCall(DSSetExtraRow(pep->ds,PETSC_TRUE)); PetscCall(DSAllocate(pep->ds,pep->ncv+1)); - PetscFunctionReturn(PETSC_SUCCESS); } diff --git a/src/pep/impls/krylov/stoar/qslice.c b/src/pep/impls/krylov/stoar/qslice.c index 148c9130a..87e73739c 100644 --- a/src/pep/impls/krylov/stoar/qslice.c +++ b/src/pep/impls/krylov/stoar/qslice.c @@ -106,7 +106,7 @@ static PetscErrorCode PEPQSliceAllocateSolution(PEP pep) PetscCall(BVDestroy(&sr->V)); PetscCall(BVCreate(PetscObjectComm((PetscObject)pep),&sr->V)); if (!pep->V) PetscCall(PEPGetBV(pep,&pep->V)); - if (!((PetscObject)(pep->V))->type_name) PetscCall(BVSetType(sr->V,BVMAT)); + if (!((PetscObject)pep->V)->type_name) PetscCall(BVSetType(sr->V,BVMAT)); else { PetscCall(BVGetType(pep->V,&type)); PetscCall(BVSetType(sr->V,type)); @@ -686,7 +686,7 @@ static PetscErrorCode PEPGetNewShiftValue(PEP pep,PetscInt side,PetscReal *newS) 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); + *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) */ PetscCheck(sr->hasEnd || sr->nleap<=5,PetscObjectComm((PetscObject)pep),PETSC_ERR_CONV_FAILED,"Unable to compute the wanted eigenvalues with open interval"); @@ -696,7 +696,7 @@ static PetscErrorCode PEPGetNewShiftValue(PEP pep,PetscInt side,PetscReal *newS) idxP=0;/* Number of values left from shift */ for (i=0;inconv;i++) { lambda = PetscRealPart(pep->eigr[i]); - if ((sr->dir)*(lambda - sPres->value) <0) idxP++; + if (sr->dir*(lambda - sPres->value) <0) idxP++; else break; } /* Avoiding subtraction of eigenvalues (might be the same).*/ @@ -705,7 +705,7 @@ static PetscErrorCode PEPGetNewShiftValue(PEP pep,PetscInt side,PetscReal *newS) } else { d_prev = PetscAbsReal(sPres->value - PetscRealPart(pep->eigr[pep->nconv-1]))/(pep->nconv+0.3); } - *newS = sPres->value + ((sr->dir)*d_prev*pep->nev)/2; + *newS = sPres->value + (sr->dir*d_prev*pep->nev)/2; sr->dirch = PETSC_FALSE; } else { /* No values found, no information for next shift */ PetscCheck(!sr->dirch,PetscObjectComm((PetscObject)pep),PETSC_ERR_PLIB,"First shift renders no information"); @@ -725,21 +725,21 @@ static PetscErrorCode PEPGetNewShiftValue(PEP pep,PetscInt side,PetscReal *newS) 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(pep->tol)) { + 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(pep->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*(pep->nev))/2; + 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*pep->nev)/2; } else { /* Last accepted value is on the left of shift. Adding to shift */ - *newS = sPres->value + ((sr->dir)*d_prev*(pep->nev))/2; + *newS = sPres->value + (sr->dir*d_prev*pep->nev)/2; } } /* End of interval can not be surpassed */ - if ((sr->dir)*(sr->int1 - *newS) < 0) *newS = sr->int1; + if (sr->dir*(sr->int1 - *newS) < 0) *newS = sr->int1; }/* of neighb[side]==null */ PetscFunctionReturn(PETSC_SUCCESS); } @@ -808,13 +808,13 @@ static PetscErrorCode PEPStoreEigenpairs(PEP pep) for (i=0;ieigr[pep->perm[i]]); err = pep->errest[pep->perm[i]]; - if ((sr->dir)*(lambda - sPres->ext[0]) > 0 && (sr->dir)*(sPres->ext[1] - lambda) > 0) {/* Valid value */ + if (sr->dir*(lambda - sPres->ext[0]) > 0 && (sr->dir)*(sPres->ext[1] - lambda) > 0) {/* Valid value */ PetscCheck(sr->indexEig+count-ndefnumEigs,PetscObjectComm((PetscObject)pep),PETSC_ERR_PLIB,"Unexpected error in Spectrum Slicing"); PetscCall(PEPQSliceCheckEigenvalueType(pep,lambda,PetscRealPart(omega[pep->perm[i]]),PETSC_FALSE)); eigr[count] = lambda; errest[count] = err; - if (((sr->dir)*(sPres->value - lambda) > 0) && ((sr->dir)*(lambda - sPres->ext[0]) > 0)) sPres->nconv[0]++; - if (((sr->dir)*(lambda - sPres->value) > 0) && ((sr->dir)*(sPres->ext[1] - lambda) > 0)) sPres->nconv[1]++; + if ((sr->dir*(sPres->value - lambda) > 0) && (sr->dir*(lambda - sPres->ext[0]) > 0)) sPres->nconv[0]++; + if ((sr->dir*(lambda - sPres->value) > 0) && (sr->dir*(sPres->ext[1] - lambda) > 0)) sPres->nconv[1]++; PetscCall(PetscArraycpy(tS+count*(d*nconv),S+pep->perm[i]*(d*ld),nconv)); PetscCall(PetscArraycpy(tS+count*(d*nconv)+nconv,S+pep->perm[i]*(d*ld)+ld,nconv)); count++; @@ -957,8 +957,8 @@ static PetscErrorCode PEPLookForDeflation(PEP pep) 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++; + if (sr->dir*(val - sPres->ext[1]) < 0) { + if (sr->dir*(val - sPres->value) < 0) count0++; else count1++; } else break; } @@ -1234,8 +1234,8 @@ static PetscErrorCode PEPSTOAR_QSlice(PEP pep,Mat B) count0=count1=0; for (j=0;jdir)*(sr->sPres->value - lambda) > 0) && ((sr->dir)*(lambda - sr->sPres->ext[0]) > 0)) count0++; - if (((sr->dir)*(lambda - sr->sPres->value) > 0) && ((sr->dir)*(sr->sPres->ext[1] - lambda) > 0)) count1++; + if ((sr->dir*(sr->sPres->value - lambda) > 0) && (sr->dir*(lambda - sr->sPres->ext[0]) > 0)) count0++; + if ((sr->dir*(lambda - sr->sPres->value) > 0) && (sr->dir*(sr->sPres->ext[1] - lambda) > 0)) count1++; } if ((count0-sr->ndef0 >= sr->sPres->nsch[0]) && (count1-sr->ndef1 >= sr->sPres->nsch[1])) pep->reason = PEP_CONVERGED_TOL; /* Update l */ diff --git a/src/pep/impls/linear/linear.c b/src/pep/impls/linear/linear.c index fc76fe2ce..775cf9280 100644 --- a/src/pep/impls/linear/linear.c +++ b/src/pep/impls/linear/linear.c @@ -302,7 +302,7 @@ static PetscErrorCode PEPSetUp_Linear(PEP pep) } else { /* implicit matrix */ PetscCheck(pep->problem_type==PEP_GENERAL,PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Must use the explicit matrix option if problem type is not general"); - if (!((PetscObject)(ctx->eps))->type_name) PetscCall(EPSSetType(ctx->eps,EPSKRYLOVSCHUR)); + if (!((PetscObject)ctx->eps)->type_name) PetscCall(EPSSetType(ctx->eps,EPSKRYLOVSCHUR)); else { PetscCall(PetscObjectTypeCompare((PetscObject)ctx->eps,EPSKRYLOVSCHUR,&ks)); PetscCheck(ks,PetscObjectComm((PetscObject)pep),PETSC_ERR_SUP,"Implicit matrix option only implemented for Krylov-Schur"); diff --git a/src/pep/interface/pepbasic.c b/src/pep/interface/pepbasic.c index bdb9c149d..87fab4c72 100644 --- a/src/pep/interface/pepbasic.c +++ b/src/pep/interface/pepbasic.c @@ -333,7 +333,7 @@ PetscErrorCode PEPDestroy(PEP *pep) PetscFunctionBegin; if (!*pep) PetscFunctionReturn(PETSC_SUCCESS); PetscValidHeaderSpecific(*pep,PEP_CLASSID,1); - if (--((PetscObject)(*pep))->refct > 0) { *pep = NULL; PetscFunctionReturn(PETSC_SUCCESS); } + if (--((PetscObject)*pep)->refct > 0) { *pep = NULL; PetscFunctionReturn(PETSC_SUCCESS); } PetscCall(PEPReset(*pep)); PetscTryTypeMethod(*pep,destroy); if ((*pep)->eigr) PetscCall(PetscFree4((*pep)->eigr,(*pep)->eigi,(*pep)->errest,(*pep)->perm)); diff --git a/src/pep/interface/peprefine.c b/src/pep/interface/peprefine.c index 1b9150ab4..c10ecc2ab 100644 --- a/src/pep/interface/peprefine.c +++ b/src/pep/interface/peprefine.c @@ -194,7 +194,7 @@ static PetscErrorCode PEPEvaluateFunctionDerivatives(PEP pep,PetscScalar alpha,P static PetscErrorCode PEPSimpleNRefSetUpSystem(PEP pep,Mat *A,PEPSimpNRefctx *ctx,PetscInt idx,Mat *Mt,Mat *T,Mat *P,PetscBool ini,Vec t,Vec v) { PetscInt i,nmat=pep->nmat,ml,m0,n0,m1,mg; - PetscInt *dnz,*onz,ncols,*cols2=NULL,*nnz; + PetscInt ncols,*cols2=NULL; PetscScalar zero=0.0,*coeffs,*coeffs2; PetscMPIInt rank,size; MPI_Comm comm; @@ -252,35 +252,6 @@ static PetscErrorCode PEPSimpleNRefSetUpSystem(PEP pep,Mat *A,PEPSimpNRefctx *ct if (rank==size-1) ml++; PetscCall(MatSetSizes(*T,ml,ml,mg+1,mg+1)); PetscCall(MatSetFromOptions(*T)); - PetscCall(MatSetUp(*T)); - /* Preallocate M */ - if (size>1) { - MatPreallocateBegin(comm,ml,ml,dnz,onz); - for (i=m0;iV) PetscCall(PEPGetBV(pep,&pep->V)); if (!oldsize) { - if (!((PetscObject)(pep->V))->type_name) PetscCall(BVSetType(pep->V,BVMAT)); + if (!((PetscObject)pep->V)->type_name) PetscCall(BVSetType(pep->V,BVMAT)); PetscCall(STMatCreateVecsEmpty(pep->st,&t,NULL)); PetscCall(BVSetSizesFromVec(pep->V,t,requestedbv)); PetscCall(VecDestroy(&t)); diff --git a/src/pep/tests/output/test3_1.out b/src/pep/tests/output/test3_1.out index 51e9cbf0d..3914d1b5e 100644 --- a/src/pep/tests/output/test3_1.out +++ b/src/pep/tests/output/test3_1.out @@ -27,7 +27,7 @@ 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 + Scaling: BOTH, alpha=0.1, its=5 Polynomial basis: CHEBYSHEV1 Refinement: SIMPLE, tol=1e-09, its=2, scheme=SCHUR Which = 7, target = 4.8 diff --git a/src/pep/tests/test1.c b/src/pep/tests/test1.c index ad04e1119..2bdca310f 100644 --- a/src/pep/tests/test1.c +++ b/src/pep/tests/test1.c @@ -49,7 +49,6 @@ int main(int argc,char **argv) PetscCall(MatCreate(PETSC_COMM_WORLD,&K)); PetscCall(MatSetSizes(K,PETSC_DECIDE,PETSC_DECIDE,N,N)); PetscCall(MatSetFromOptions(K)); - PetscCall(MatSetUp(K)); PetscCall(MatGetOwnershipRange(K,&Istart,&Iend)); for (II=Istart;II0) PetscCall(MatSetValue(K,i,i-1,-kappa,INSERT_VALUES)); @@ -81,7 +80,6 @@ int main(int argc,char **argv) PetscCall(MatCreate(PETSC_COMM_WORLD,&C)); PetscCall(MatSetSizes(C,PETSC_DECIDE,PETSC_DECIDE,n,n)); PetscCall(MatSetFromOptions(C)); - PetscCall(MatSetUp(C)); PetscCall(MatGetOwnershipRange(C,&Istart,&Iend)); for (i=Istart;i0) PetscCall(MatSetValue(C,i,i-1,-tau,INSERT_VALUES)); @@ -95,7 +93,6 @@ int main(int argc,char **argv) PetscCall(MatCreate(PETSC_COMM_WORLD,&M)); PetscCall(MatSetSizes(M,PETSC_DECIDE,PETSC_DECIDE,n,n)); PetscCall(MatSetFromOptions(M)); - PetscCall(MatSetUp(M)); PetscCall(MatGetOwnershipRange(M,&Istart,&Iend)); for (i=Istart;i=Istart && n-1=Istart && nele-1omega,INSERT_VALUES)); PetscCall(EPSSetOperators(cross->eps,cross->C,Omega)); PetscCall(EPSSetProblemType(cross->eps,EPS_GHIEP)); diff --git a/src/svd/impls/cyclic/cyclic.c b/src/svd/impls/cyclic/cyclic.c index 32b06cc0e..02ac2ffd7 100644 --- a/src/svd/impls/cyclic/cyclic.c +++ b/src/svd/impls/cyclic/cyclic.c @@ -95,7 +95,6 @@ static PetscErrorCode SVDCyclicGetCyclicMat(SVD svd,Mat A,Mat AT,Mat *C) PetscCall(MatCreate(PetscObjectComm((PetscObject)svd),&Zm)); PetscCall(MatSetSizes(Zm,m,m,M,M)); PetscCall(MatSetFromOptions(Zm)); - PetscCall(MatSetUp(Zm)); PetscCall(MatGetOwnershipRange(Zm,&Istart,&Iend)); for (i=Istart;ieps,cyclic->C,Omega)); PetscCall(EPSSetProblemType(cyclic->eps,EPS_GHIEP)); diff --git a/src/svd/impls/external/ksvd/svdksvd.c b/src/svd/impls/external/ksvd/svdksvd.c index 04575842b..dd22820b3 100644 --- a/src/svd/impls/external/ksvd/svdksvd.c +++ b/src/svd/impls/external/ksvd/svdksvd.c @@ -69,14 +69,12 @@ static PetscErrorCode SVDSolve_KSVD(SVD svd) PetscCall(MatCreate(PetscObjectComm((PetscObject)A),&Z)); PetscCall(MatSetSizes(Z,m,mn,PETSC_DECIDE,PETSC_DECIDE)); PetscCall(MatSetType(Z,MATSCALAPACK)); - PetscCall(MatSetUp(Z)); PetscCall(MatAssemblyBegin(Z,MAT_FINAL_ASSEMBLY)); PetscCall(MatAssemblyEnd(Z,MAT_FINAL_ASSEMBLY)); z = (Mat_ScaLAPACK*)Z->data; PetscCall(MatCreate(PetscObjectComm((PetscObject)A),&Q)); PetscCall(MatSetSizes(Q,mn,n,PETSC_DECIDE,PETSC_DECIDE)); PetscCall(MatSetType(Q,MATSCALAPACK)); - PetscCall(MatSetUp(Q)); PetscCall(MatAssemblyBegin(Q,MAT_FINAL_ASSEMBLY)); PetscCall(MatAssemblyEnd(Q,MAT_FINAL_ASSEMBLY)); q = (Mat_ScaLAPACK*)Q->data; diff --git a/src/svd/impls/external/scalapack/svdscalap.c b/src/svd/impls/external/scalapack/svdscalap.c index 214e856aa..670c13101 100644 --- a/src/svd/impls/external/scalapack/svdscalap.c +++ b/src/svd/impls/external/scalapack/svdscalap.c @@ -60,14 +60,12 @@ static PetscErrorCode SVDSolve_ScaLAPACK(SVD svd) PetscCall(MatCreate(PetscObjectComm((PetscObject)A),&Z)); PetscCall(MatSetSizes(Z,m,mn,PETSC_DECIDE,PETSC_DECIDE)); PetscCall(MatSetType(Z,MATSCALAPACK)); - PetscCall(MatSetUp(Z)); PetscCall(MatAssemblyBegin(Z,MAT_FINAL_ASSEMBLY)); PetscCall(MatAssemblyEnd(Z,MAT_FINAL_ASSEMBLY)); z = (Mat_ScaLAPACK*)Z->data; PetscCall(MatCreate(PetscObjectComm((PetscObject)A),&QT)); PetscCall(MatSetSizes(QT,mn,n,PETSC_DECIDE,PETSC_DECIDE)); PetscCall(MatSetType(QT,MATSCALAPACK)); - PetscCall(MatSetUp(QT)); PetscCall(MatAssemblyBegin(QT,MAT_FINAL_ASSEMBLY)); PetscCall(MatAssemblyEnd(QT,MAT_FINAL_ASSEMBLY)); q = (Mat_ScaLAPACK*)QT->data; diff --git a/src/svd/interface/svdbasic.c b/src/svd/interface/svdbasic.c index 29f18a059..9729ffe15 100644 --- a/src/svd/interface/svdbasic.c +++ b/src/svd/interface/svdbasic.c @@ -171,7 +171,7 @@ PetscErrorCode SVDDestroy(SVD *svd) PetscFunctionBegin; if (!*svd) PetscFunctionReturn(PETSC_SUCCESS); PetscValidHeaderSpecific(*svd,SVD_CLASSID,1); - if (--((PetscObject)(*svd))->refct > 0) { *svd = NULL; PetscFunctionReturn(PETSC_SUCCESS); } + if (--((PetscObject)*svd)->refct > 0) { *svd = NULL; PetscFunctionReturn(PETSC_SUCCESS); } PetscCall(SVDReset(*svd)); PetscTryTypeMethod(*svd,destroy); if ((*svd)->sigma) PetscCall(PetscFree3((*svd)->sigma,(*svd)->perm,(*svd)->errest)); diff --git a/src/svd/interface/svdsetup.c b/src/svd/interface/svdsetup.c index 5e114823a..e5ce0925f 100644 --- a/src/svd/interface/svdsetup.c +++ b/src/svd/interface/svdsetup.c @@ -502,7 +502,7 @@ PetscErrorCode SVDAllocateSolution(SVD svd,PetscInt extra) /* allocate V */ if (!svd->V) PetscCall(SVDGetBV(svd,&svd->V,NULL)); if (!oldsize) { - if (!((PetscObject)(svd->V))->type_name) PetscCall(BVSetType(svd->V,BVMAT)); + if (!((PetscObject)svd->V)->type_name) PetscCall(BVSetType(svd->V,BVMAT)); PetscCall(MatCreateVecsEmpty(svd->A,&tr,NULL)); PetscCall(BVSetSizesFromVec(svd->V,tr,requested)); PetscCall(VecDestroy(&tr)); @@ -511,7 +511,7 @@ PetscErrorCode SVDAllocateSolution(SVD svd,PetscInt extra) if (svd->leftbasis && !svd->isgeneralized) { if (!svd->U) PetscCall(SVDGetBV(svd,NULL,&svd->U)); if (!oldsize) { - if (!((PetscObject)(svd->U))->type_name) PetscCall(BVSetType(svd->U,((PetscObject)(svd->V))->type_name)); + if (!((PetscObject)svd->U)->type_name) PetscCall(BVSetType(svd->U,((PetscObject)svd->V)->type_name)); PetscCall(MatCreateVecsEmpty(svd->A,NULL,&tl)); PetscCall(BVSetSizesFromVec(svd->U,tl,requested)); PetscCall(VecDestroy(&tl)); @@ -519,7 +519,7 @@ PetscErrorCode SVDAllocateSolution(SVD svd,PetscInt extra) } else if (svd->isgeneralized) { /* left basis for the GSVD */ if (!svd->U) PetscCall(SVDGetBV(svd,NULL,&svd->U)); if (!oldsize) { - if (!((PetscObject)(svd->U))->type_name) PetscCall(BVSetType(svd->U,((PetscObject)(svd->V))->type_name)); + if (!((PetscObject)svd->U)->type_name) PetscCall(BVSetType(svd->U,((PetscObject)svd->V)->type_name)); PetscCall(SVDCreateLeftTemplate(svd,&tl)); PetscCall(BVSetSizesFromVec(svd->U,tl,requested)); PetscCall(VecDestroy(&tl)); diff --git a/src/svd/interface/svdsolve.c b/src/svd/interface/svdsolve.c index c45c36ee9..351ab4425 100644 --- a/src/svd/interface/svdsolve.c +++ b/src/svd/interface/svdsolve.c @@ -31,7 +31,7 @@ PetscErrorCode SVDComputeVectors_Left(SVD svd) if (!svd->U) PetscCall(SVDGetBV(svd,NULL,&svd->U)); PetscCall(BVGetSizes(svd->U,NULL,NULL,&oldsize)); if (!oldsize) { - if (!((PetscObject)(svd->U))->type_name) PetscCall(BVSetType(svd->U,((PetscObject)(svd->V))->type_name)); + if (!((PetscObject)svd->U)->type_name) PetscCall(BVSetType(svd->U,((PetscObject)svd->V)->type_name)); PetscCall(MatCreateVecsEmpty(svd->A,NULL,&tl)); PetscCall(BVSetSizesFromVec(svd->U,tl,svd->ncv)); PetscCall(VecDestroy(&tl)); diff --git a/src/svd/tests/output/test5_1.out b/src/svd/tests/output/test5_1.out index 0525c6314..5f7312d81 100644 --- a/src/svd/tests/output/test5_1.out +++ b/src/svd/tests/output/test5_1.out @@ -63,6 +63,16 @@ removed 2.000000 removed 1.000000 removed ---------------------- -------------------- + ---------------------- -------------------- + sigma ||r||/||A|| + ---------------------- -------------------- + 6.000000 removed + 5.000000 removed + 4.000000 removed + 3.000000 removed + 2.000000 removed + 1.000000 removed + ---------------------- -------------------- Singular values = 6.00000 5.00000 diff --git a/src/svd/tests/test1.c b/src/svd/tests/test1.c index 115721b54..c7b410575 100644 --- a/src/svd/tests/test1.c +++ b/src/svd/tests/test1.c @@ -58,7 +58,6 @@ int main(int argc,char **argv) PetscCall(MatCreate(PETSC_COMM_WORLD,&A)); PetscCall(MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,N,N)); PetscCall(MatSetFromOptions(A)); - PetscCall(MatSetUp(A)); PetscCall(MatGetOwnershipRange(A,&Istart,&Iend)); for (i=Istart;invertices,PETSC_COMM_SELF,PETSC_ERR_ORDER,"Must call GraphPreload() first"); - PetscCall(MatDestroy(&(graph->adjacency))); + PetscCall(MatDestroy(&graph->adjacency)); PetscCall(MatCreate(graph->comm,&graph->adjacency)); PetscCall(MatSetSizes(graph->adjacency,PETSC_DECIDE,PETSC_DECIDE,graph->nvertices,graph->nvertices)); PetscCall(MatSetType(graph->adjacency,MATAIJ)); - PetscCall(MatSetUp(graph->adjacency)); /* otherwise MatGetOwnershipRange() cannot be called */ PetscCall(MatGetOwnershipRange(graph->adjacency,&Istart,&Iend)); PetscCall(PetscCalloc2(Iend-Istart,&d_nnz,Iend-Istart,&o_nnz)); diff --git a/src/svd/tutorials/ex15.c b/src/svd/tutorials/ex15.c index 5f0030eab..33a5e8a99 100644 --- a/src/svd/tutorials/ex15.c +++ b/src/svd/tutorials/ex15.c @@ -38,7 +38,6 @@ int main(int argc,char **argv) PetscCall(MatCreate(PETSC_COMM_WORLD,&A)); PetscCall(MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n+1,n)); PetscCall(MatSetFromOptions(A)); - PetscCall(MatSetUp(A)); PetscCall(MatGetOwnershipRange(A,&Istart,&Iend)); for (i=Istart;iAcreate)) { PetscCall(MatGetType(bv->Acreate,&mtype)); PetscCall(PetscStrcmpAny(mtype,&isdense,MATSEQDENSE,MATMPIDENSE,"")); - PetscCheck(isdense,PetscObjectComm((PetscObject)bv->Acreate),PETSC_ERR_SUP,"BVCONTIGUOUS requires a dense matrix in BVCreateFromMat()\n"); + PetscCheck(isdense,PetscObjectComm((PetscObject)bv->Acreate),PETSC_ERR_SUP,"BVCONTIGUOUS requires a dense matrix in BVCreateFromMat()"); PetscCall(MatDenseGetArray(bv->Acreate,&aa)); PetscCall(MatDenseGetLDA(bv->Acreate,&lda)); for (j=0;jm;j++) PetscCall(PetscArraycpy(ctx->array+j*bv->ld,aa+j*lda,bv->n)); diff --git a/src/sys/classes/bv/impls/cuda/bvcuda.cu b/src/sys/classes/bv/impls/cuda/bvcuda.cu index 2b4f703dd..346636abb 100644 --- a/src/sys/classes/bv/impls/cuda/bvcuda.cu +++ b/src/sys/classes/bv/impls/cuda/bvcuda.cu @@ -203,7 +203,7 @@ PetscErrorCode BVDot_BLAS_CUDA(BV bv,PetscInt m_,PetscInt n_,PetscInt k_,const P */ PetscErrorCode BVDotVec_BLAS_CUDA(BV bv,PetscInt n_,PetscInt k_,const PetscScalar *d_A,PetscInt lda_,const PetscScalar *d_x,PetscScalar *y,PetscBool mpi) { - PetscScalar *d_work,szero=0.0,sone=1.0,*yy=y; + PetscScalar *d_work,szero=0.0,sone=1.0,*yy; PetscCuBLASInt n=0,k=0,lda=0,one=1; PetscMPIInt len; cublasHandle_t cublasv2handle; @@ -229,12 +229,28 @@ PetscErrorCode BVDotVec_BLAS_CUDA(BV bv,PetscInt n_,PetscInt k_,const PetscScala PetscCallCUDA(cudaMemcpy(bv->work,d_work,k*sizeof(PetscScalar),cudaMemcpyDeviceToHost)); PetscCall(PetscLogGpuToCpu(k*sizeof(PetscScalar))); } else PetscCall(PetscArrayzero(bv->work,k)); + /* reduction */ + PetscCall(PetscMPIIntCast(k,&len)); if (!y) { + if (use_gpu_aware_mpi) { /* case 1: reduce on GPU using a temporary buffer */ + PetscCallCUDA(cudaMalloc((void**)&yy,k*sizeof(PetscScalar))); + PetscCall(MPIU_Allreduce(d_work,yy,len,MPIU_SCALAR,MPIU_SUM,PetscObjectComm((PetscObject)bv))); + PetscCallCUDA(cudaMemcpy(d_work,yy,k*sizeof(PetscScalar),cudaMemcpyDeviceToDevice)); + PetscCallCUDA(cudaFree(yy)); + } else { /* case 2: reduce on CPU, copy result back to GPU */ + PetscCall(BVAllocateWork_Private(bv,2*k)); + yy = bv->work+k; + PetscCallCUDA(cudaMemcpy(bv->work,d_work,k*sizeof(PetscScalar),cudaMemcpyDeviceToHost)); + PetscCall(PetscLogGpuToCpu(k*sizeof(PetscScalar))); + PetscCall(MPIU_Allreduce(bv->work,yy,len,MPIU_SCALAR,MPIU_SUM,PetscObjectComm((PetscObject)bv))); + PetscCallCUDA(cudaMemcpy(d_work,yy,k*sizeof(PetscScalar),cudaMemcpyHostToDevice)); + PetscCall(PetscLogCpuToGpu(k*sizeof(PetscScalar))); + } PetscCall(VecCUDARestoreArrayWrite(bv->buffer,&d_work)); - PetscCall(VecGetArray(bv->buffer,&yy)); - } else PetscCallCUDA(cudaFree(d_work)); - PetscCall(PetscMPIIntCast(k,&len)); - PetscCall(MPIU_Allreduce(bv->work,yy,len,MPIU_SCALAR,MPIU_SUM,PetscObjectComm((PetscObject)bv))); + } else { /* case 3: user-provided array y, reduce on CPU */ + PetscCallCUDA(cudaFree(d_work)); + PetscCall(MPIU_Allreduce(bv->work,y,len,MPIU_SCALAR,MPIU_SUM,PetscObjectComm((PetscObject)bv))); + } } else { if (n) { PetscCall(PetscLogGpuTimeBegin()); diff --git a/src/sys/classes/bv/impls/svec/svec.c b/src/sys/classes/bv/impls/svec/svec.c index 51863a267..4be827548 100644 --- a/src/sys/classes/bv/impls/svec/svec.c +++ b/src/sys/classes/bv/impls/svec/svec.c @@ -460,7 +460,7 @@ SLEPC_EXTERN PetscErrorCode BVCreate_Svec(BV bv) if (PetscUnlikely(bv->Acreate)) { PetscCall(MatGetType(bv->Acreate,&mtype)); PetscCall(PetscStrcmpAny(mtype,&isdense,MATSEQDENSE,MATMPIDENSE,"")); - PetscCheck(isdense,PetscObjectComm((PetscObject)bv->Acreate),PETSC_ERR_SUP,"BVSVEC requires a dense matrix in BVCreateFromMat()\n"); + PetscCheck(isdense,PetscObjectComm((PetscObject)bv->Acreate),PETSC_ERR_SUP,"BVSVEC requires a dense matrix in BVCreateFromMat()"); PetscCall(MatDenseGetArrayRead(bv->Acreate,&aa)); PetscCall(MatDenseGetLDA(bv->Acreate,&lda)); PetscCall(VecGetArray(ctx->v,&vv)); diff --git a/src/sys/classes/bv/interface/bvfunc.c b/src/sys/classes/bv/interface/bvfunc.c index c0e4cd395..e220fe290 100644 --- a/src/sys/classes/bv/interface/bvfunc.c +++ b/src/sys/classes/bv/interface/bvfunc.c @@ -118,8 +118,8 @@ PetscErrorCode BVDestroy(BV *bv) PetscFunctionBegin; if (!*bv) PetscFunctionReturn(PETSC_SUCCESS); PetscValidHeaderSpecific(*bv,BV_CLASSID,1); - PetscCheck(!(*bv)->lsplit,PetscObjectComm((PetscObject)(*bv)),PETSC_ERR_ARG_WRONGSTATE,"Must call BVRestoreSplit before destroying the BV"); - if (--((PetscObject)(*bv))->refct > 0) { *bv = NULL; PetscFunctionReturn(PETSC_SUCCESS); } + PetscCheck(!(*bv)->lsplit,PetscObjectComm((PetscObject)*bv),PETSC_ERR_ARG_WRONGSTATE,"Must call BVRestoreSplit before destroying the BV"); + if (--((PetscObject)*bv)->refct > 0) { *bv = NULL; PetscFunctionReturn(PETSC_SUCCESS); } PetscTryTypeMethod(*bv,destroy); PetscCall(PetscLayoutDestroy(&(*bv)->map)); PetscCall(PetscFree((*bv)->vtype)); diff --git a/src/sys/classes/bv/interface/bvorthog.c b/src/sys/classes/bv/interface/bvorthog.c index d272a4a63..39fd964e3 100644 --- a/src/sys/classes/bv/interface/bvorthog.c +++ b/src/sys/classes/bv/interface/bvorthog.c @@ -131,7 +131,7 @@ static PetscErrorCode BVOrthogonalizeCGS1(BV bv,PetscInt j,Vec v,PetscBool *whic PetscFunctionReturn(PETSC_SUCCESS); } -#define BVOrthogonalizeGS1(a,b,c,d,e,f,g,h) ((bv->ops->gramschmidt)?(*bv->ops->gramschmidt):(mgs?BVOrthogonalizeMGS1:BVOrthogonalizeCGS1))(a,b,c,d,e,f,g,h) +#define BVOrthogonalizeGS1(a,b,c,d,e,f,g,h) (bv->ops->gramschmidt?(*bv->ops->gramschmidt):(mgs?BVOrthogonalizeMGS1:BVOrthogonalizeCGS1))(a,b,c,d,e,f,g,h) /* BVOrthogonalizeGS - Orthogonalize with (classical or modified) Gram-Schmidt diff --git a/src/sys/classes/bv/tests/test11.c b/src/sys/classes/bv/tests/test11.c index fd158e520..9087f2e56 100644 --- a/src/sys/classes/bv/tests/test11.c +++ b/src/sys/classes/bv/tests/test11.c @@ -96,7 +96,6 @@ int main(int argc,char **argv) PetscCall(MatCreate(PETSC_COMM_WORLD,&B)); PetscCall(MatSetSizes(B,PETSC_DECIDE,PETSC_DECIDE,n,n)); PetscCall(MatSetFromOptions(B)); - PetscCall(MatSetUp(B)); PetscCall(PetscObjectSetName((PetscObject)B,"B")); PetscCall(MatGetOwnershipRange(B,&Istart,&Iend)); diff --git a/src/sys/classes/bv/tests/test14.c b/src/sys/classes/bv/tests/test14.c index cd1e091f4..5358af96a 100644 --- a/src/sys/classes/bv/tests/test14.c +++ b/src/sys/classes/bv/tests/test14.c @@ -34,7 +34,7 @@ int main(int argc,char **argv) PetscCall(MatCreate(PETSC_COMM_WORLD,&A)); PetscCall(MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,k)); if (!sparse) PetscCall(MatSetType(A,MATDENSE)); - PetscCall(MatSetUp(A)); + else PetscCall(MatSetType(A,MATAIJ)); PetscCall(MatGetOwnershipRange(A,&Istart,&Iend)); for (j=0;j0 && i-1n[1],&n1_)); if (tr1->n[0] > 1) PetscCallBLAS("LAPACKlarfg",LAPACKlarfg_(&n0_,x+tr1->idx[0],x+tr1->idx[0]+1,&inc,tr1->tau)); if (tr1->n[1]> 1) PetscCallBLAS("LAPACKlarfg",LAPACKlarfg_(&n1_,x+tr1->idx[1],x+tr1->idx[1]+1,&inc,tr1->tau+1)); - if (tr1->idx[0]idx[1]) PetscCall(HRGen(PetscRealPart(x[tr1->idx[0]]),PetscRealPart(x[tr1->idx[1]]),&(tr1->type),&(tr1->cs),&(tr1->sn),&(tr1->alpha),ncond)); + if (tr1->idx[0]idx[1]) PetscCall(HRGen(PetscRealPart(x[tr1->idx[0]]),PetscRealPart(x[tr1->idx[1]]),&tr1->type,&tr1->cs,&tr1->sn,&tr1->alpha,ncond)); else { tr1->alpha = PetscRealPart(x[tr1->idx[0]]); *ncond = 1.0; @@ -326,7 +326,7 @@ static PetscErrorCode MadeHRtr(PetscInt sz,PetscInt n,PetscInt idx0,PetscInt n0, PetscCall(PetscBLASIntCast(tr2->n[1],&n1_)); if (tr2->n[0] > 1) PetscCallBLAS("LAPACKlarfg",LAPACKlarfg_(&n0_,y+tr2->idx[0],y+tr2->idx[0]+1,&inc,tr2->tau)); if (tr2->n[1]> 1) PetscCallBLAS("LAPACKlarfg",LAPACKlarfg_(&n1_,y+tr2->idx[1],y+tr2->idx[1]+1,&inc,tr2->tau+1)); - if (tr2->idx[0]idx[1]) PetscCall(HRGen(PetscRealPart(y[tr2->idx[0]]),PetscRealPart(y[tr2->idx[1]]),&(tr2->type),&(tr2->cs),&(tr2->sn),&(tr2->alpha),&ncond2)); + if (tr2->idx[0]idx[1]) PetscCall(HRGen(PetscRealPart(y[tr2->idx[0]]),PetscRealPart(y[tr2->idx[1]]),&tr2->type,&tr2->cs,&tr2->sn,&tr2->alpha,&ncond2)); else { tr2->alpha = PetscRealPart(y[tr2->idx[0]]); ncond2 = 1.0; diff --git a/src/sys/classes/ds/impls/hsvd/dshsvd.c b/src/sys/classes/ds/impls/hsvd/dshsvd.c index 5923d7219..26a9eaf59 100644 --- a/src/sys/classes/ds/impls/hsvd/dshsvd.c +++ b/src/sys/classes/ds/impls/hsvd/dshsvd.c @@ -402,6 +402,7 @@ static PetscErrorCode DSSynchronize_HSVD(DS ds,PetscScalar eigr[],PetscScalar ei PetscFunctionBegin; if (ds->compact) kr = 3*ld; else k = (ds->n-l)*ld; + kr += ld; if (ds->state>DS_STATE_RAW) k += 2*(ds->n-l)*ld; if (eigr) k += ds->n-l; PetscCall(DSAllocateWork_Private(ds,k+kr,0,0)); diff --git a/src/sys/classes/ds/interface/dsbasic.c b/src/sys/classes/ds/interface/dsbasic.c index eff2d7652..02ec22249 100644 --- a/src/sys/classes/ds/interface/dsbasic.c +++ b/src/sys/classes/ds/interface/dsbasic.c @@ -906,7 +906,7 @@ PetscErrorCode DSDestroy(DS *ds) PetscFunctionBegin; if (!*ds) PetscFunctionReturn(PETSC_SUCCESS); PetscValidHeaderSpecific(*ds,DS_CLASSID,1); - if (--((PetscObject)(*ds))->refct > 0) { *ds = NULL; PetscFunctionReturn(PETSC_SUCCESS); } + if (--((PetscObject)*ds)->refct > 0) { *ds = NULL; PetscFunctionReturn(PETSC_SUCCESS); } PetscCall(DSReset(*ds)); PetscTryTypeMethod(*ds,destroy); PetscCall(PetscFree((*ds)->work)); diff --git a/src/sys/classes/ds/tests/test26.c b/src/sys/classes/ds/tests/test26.c index 843fea57b..ef8e30932 100644 --- a/src/sys/classes/ds/tests/test26.c +++ b/src/sys/classes/ds/tests/test26.c @@ -20,7 +20,7 @@ int main(int argc,char **argv) PetscScalar *U,*w,d; PetscInt i,n=10,m,l=2,k=5,p=1,ld; PetscViewer viewer; - PetscBool verbose,extrarow; + PetscBool verbose,extrarow,reorthog,flg; PetscFunctionBeginUser; PetscCall(SlepcInitialize(&argc,&argv,(char*)0,help)); @@ -33,6 +33,7 @@ int main(int argc,char **argv) PetscCheck(l<=n && k<=n && l<=k && p>=0 && p<=n-l,PETSC_COMM_WORLD,PETSC_ERR_USER_INPUT,"Wrong value of dimensions"); PetscCall(PetscOptionsHasName(NULL,NULL,"-verbose",&verbose)); PetscCall(PetscOptionsHasName(NULL,NULL,"-extrarow",&extrarow)); + PetscCall(PetscOptionsHasName(NULL,NULL,"-reorthog",&reorthog)); /* Create DS object */ PetscCall(DSCreate(PETSC_COMM_WORLD,&ds)); @@ -44,6 +45,9 @@ int main(int argc,char **argv) PetscCall(DSHSVDSetDimensions(ds,m)); PetscCall(DSSetCompact(ds,PETSC_TRUE)); PetscCall(DSSetExtraRow(ds,extrarow)); + PetscCall(DSHSVDSetReorthogonalize(ds,reorthog)); + PetscCall(DSHSVDGetReorthogonalize(ds,&flg)); + if (flg) PetscCall(PetscPrintf(PETSC_COMM_WORLD,"reorthogonalizing\n")); /* Set up viewer */ PetscCall(PetscViewerASCIIGetStdout(PETSC_COMM_WORLD,&viewer)); @@ -118,8 +122,9 @@ int main(int argc,char **argv) requires: !single test: - args: -extrarow + args: -extrarow -reorthog {{0 1}} suffix: 3 requires: !single + filter: grep -v reorthogonalizing TEST*/ diff --git a/src/sys/classes/fn/interface/fnbasic.c b/src/sys/classes/fn/interface/fnbasic.c index 9466e310f..77746f3fa 100644 --- a/src/sys/classes/fn/interface/fnbasic.c +++ b/src/sys/classes/fn/interface/fnbasic.c @@ -1032,7 +1032,7 @@ PetscErrorCode FNDestroy(FN *fn) PetscFunctionBegin; if (!*fn) PetscFunctionReturn(PETSC_SUCCESS); PetscValidHeaderSpecific(*fn,FN_CLASSID,1); - if (--((PetscObject)(*fn))->refct > 0) { *fn = NULL; PetscFunctionReturn(PETSC_SUCCESS); } + if (--((PetscObject)*fn)->refct > 0) { *fn = NULL; PetscFunctionReturn(PETSC_SUCCESS); } PetscTryTypeMethod(*fn,destroy); for (i=0;i<(*fn)->nw;i++) PetscCall(MatDestroy(&(*fn)->W[i])); PetscCall(PetscHeaderDestroy(fn)); diff --git a/src/sys/classes/rg/interface/rgbasic.c b/src/sys/classes/rg/interface/rgbasic.c index 27f7bd871..e85804c8f 100644 --- a/src/sys/classes/rg/interface/rgbasic.c +++ b/src/sys/classes/rg/interface/rgbasic.c @@ -677,7 +677,7 @@ PetscErrorCode RGSetComplement(RG rg,PetscBool flg) } /*@ - RGGetComplement - Gets a flag that that indicates whether the region + RGGetComplement - Gets a flag that indicates whether the region is complemented or not. Not Collective @@ -824,7 +824,7 @@ PetscErrorCode RGDestroy(RG *rg) PetscFunctionBegin; if (!*rg) PetscFunctionReturn(PETSC_SUCCESS); PetscValidHeaderSpecific(*rg,RG_CLASSID,1); - if (--((PetscObject)(*rg))->refct > 0) { *rg = NULL; PetscFunctionReturn(PETSC_SUCCESS); } + if (--((PetscObject)*rg)->refct > 0) { *rg = NULL; PetscFunctionReturn(PETSC_SUCCESS); } PetscTryTypeMethod(*rg,destroy); PetscCall(PetscHeaderDestroy(rg)); PetscFunctionReturn(PETSC_SUCCESS); diff --git a/src/sys/classes/st/impls/filter/filter.c b/src/sys/classes/st/impls/filter/filter.c index d80c278df..ec06655c1 100644 --- a/src/sys/classes/st/impls/filter/filter.c +++ b/src/sys/classes/st/impls/filter/filter.c @@ -21,7 +21,7 @@ */ static PetscErrorCode STComputeOperator_Filter(ST st) { - ST_FILTER *ctx = (ST_FILTER*)st->data; + ST_FILTER *ctx = (ST_FILTER*)st->data; PetscFunctionBegin; PetscCheck(st->nmat==1,PetscObjectComm((PetscObject)st),PETSC_ERR_SUP,"Only implemented for standard eigenvalue problem"); @@ -48,9 +48,9 @@ static PetscErrorCode STSetUp_Filter(ST st) static PetscErrorCode STSetFromOptions_Filter(ST st,PetscOptionItems *PetscOptionsObject) { - PetscReal array[2]={0,0}; - PetscInt k; - PetscBool flg; + PetscReal array[2]={0,0}; + PetscInt k; + PetscBool flg; PetscFunctionBegin; PetscOptionsHeadBegin(PetscOptionsObject,"ST Filter Options"); @@ -359,7 +359,7 @@ PetscErrorCode STFilterGetThreshold(ST st,PetscReal *gamma) static PetscErrorCode STReset_Filter(ST st) { - ST_FILTER *ctx = (ST_FILTER*)st->data; + ST_FILTER *ctx = (ST_FILTER*)st->data; PetscFunctionBegin; ctx->left = 0.0; @@ -372,8 +372,8 @@ static PetscErrorCode STReset_Filter(ST st) static PetscErrorCode STView_Filter(ST st,PetscViewer viewer) { - ST_FILTER *ctx = (ST_FILTER*)st->data; - PetscBool isascii; + ST_FILTER *ctx = (ST_FILTER*)st->data; + PetscBool isascii; PetscFunctionBegin; PetscCall(PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii)); @@ -388,7 +388,7 @@ static PetscErrorCode STView_Filter(ST st,PetscViewer viewer) static PetscErrorCode STDestroy_Filter(ST st) { - ST_FILTER *ctx = (ST_FILTER*)st->data; + ST_FILTER *ctx = (ST_FILTER*)st->data; PetscFunctionBegin; PetscCall(PetscFree(ctx->opts)); @@ -407,9 +407,10 @@ static PetscErrorCode STDestroy_Filter(ST st) SLEPC_EXTERN PetscErrorCode STCreate_Filter(ST st) { - ST_FILTER *ctx; - FILTLAN_IOP iop; - FILTLAN_PFI pfi; + ST_FILTER *ctx; + FILTLAN_IOP iop; + FILTLAN_PFI pfi; + PetscFunctionBegin; PetscCall(PetscNew(&ctx)); st->data = (void*)ctx; diff --git a/src/sys/classes/st/impls/filter/filtlan.c b/src/sys/classes/st/impls/filter/filtlan.c index e7917b80c..f1b61603f 100644 --- a/src/sys/classes/st/impls/filter/filtlan.c +++ b/src/sys/classes/st/impls/filter/filtlan.c @@ -229,7 +229,7 @@ static PetscErrorCode FILTLAN_GetIntervals(PetscReal *intervals,PetscReal *frame leftDelta = (b1-a1)*opts->initialShiftStep; /* initial left shift */ rightDelta = leftDelta; /* initial right shift */ opts->numGridPoints = PetscMax(opts->numGridPoints,(PetscInt)(2.0*(b-a)/halfPlateau)); - gridSize = (b-a) / (PetscReal)(opts->numGridPoints); + gridSize = (b-a) / (PetscReal)opts->numGridPoints; for (i=0;i<6;i++) intv[i] = 0.0; if (filterInfo->filterType == 2) { /* for interior eigenvalues */ diff --git a/src/sys/classes/st/impls/shell/shell.c b/src/sys/classes/st/impls/shell/shell.c index 9fc15c4f4..59736af62 100644 --- a/src/sys/classes/st/impls/shell/shell.c +++ b/src/sys/classes/st/impls/shell/shell.c @@ -49,7 +49,7 @@ PetscErrorCode STShellGetContext(ST st,void *ctx) PetscAssertPointer(ctx,2); PetscCall(PetscObjectTypeCompare((PetscObject)st,STSHELL,&flg)); if (!flg) *(void**)ctx = NULL; - else *(void**)ctx = ((ST_SHELL*)(st->data))->ctx; + else *(void**)ctx = ((ST_SHELL*)st->data)->ctx; PetscFunctionReturn(PETSC_SUCCESS); } @@ -117,6 +117,7 @@ static PetscErrorCode STApplyTranspose_Shell(ST st,Vec x,Vec y) PetscFunctionReturn(PETSC_SUCCESS); } +#if defined(PETSC_USE_COMPLEX) static PetscErrorCode STApplyHermitianTranspose_Shell(ST st,Vec x,Vec y) { ST_SHELL *shell = (ST_SHELL*)st->data; @@ -136,18 +137,13 @@ static PetscErrorCode STApplyHermitianTranspose_Shell(ST st,Vec x,Vec y) PetscCall(VecDuplicate(x,&w)); PetscCall(VecCopy(x,w)); PetscCall(VecConjugate(w)); - PetscCall(PetscObjectStateGet((PetscObject)y,&instate)); - PetscCallBack("STSHELL user function applytrans()",(*shell->applytrans)(st,w,y)); - PetscCall(PetscObjectStateGet((PetscObject)y,&outstate)); - if (instate == outstate) { - /* user forgot to increase the state of the output vector */ - PetscCall(PetscObjectStateIncrease((PetscObject)y)); - } + PetscCall(STApplyTranspose_Shell(st,w,y)); PetscCall(VecDestroy(&w)); PetscCall(VecConjugate(y)); } PetscFunctionReturn(PETSC_SUCCESS); } +#endif static PetscErrorCode STBackTransform_Shell(ST st,PetscInt n,PetscScalar *eigr,PetscScalar *eigi) { @@ -255,6 +251,7 @@ PetscErrorCode STShellSetApplyTranspose(ST st,PetscErrorCode (*applytrans)(ST st PetscFunctionReturn(PETSC_SUCCESS); } +#if defined(PETSC_USE_COMPLEX) static PetscErrorCode STShellSetApplyHermitianTranspose_Shell(ST st,PetscErrorCode (*applyhermtrans)(ST,Vec,Vec)) { ST_SHELL *shell = (ST_SHELL*)st->data; @@ -263,6 +260,7 @@ static PetscErrorCode STShellSetApplyHermitianTranspose_Shell(ST st,PetscErrorCo shell->applyhermtrans = applyhermtrans; PetscFunctionReturn(PETSC_SUCCESS); } +#endif /*@C STShellSetApplyHermitianTranspose - Sets routine to use as the application of the @@ -280,6 +278,10 @@ static PetscErrorCode STShellSetApplyHermitianTranspose_Shell(ST st,PetscErrorCo . xin - input vector - xout - output vector + Note: + If configured with real scalars, this function has the same effect as STShellSetApplyTranspose(), + so no need to call both. + Level: advanced .seealso: STShellSetApply(), STShellSetApplyTranspose(), STShellSetBackTransform() @@ -349,7 +351,7 @@ PetscErrorCode STShellSetBackTransform(ST st,PetscErrorCode (*backtr)(ST st,Pets $ STShellSetContext(st,ctx); $ STShellSetApply(st,apply); $ STShellSetApplyTranspose(st,applytrans); (optional) -$ STShellSetApplyHermitianTranspose(st,applyht); (optional) +$ STShellSetApplyHermitianTranspose(st,applyht); (optional, only in complex scalars) $ STShellSetBackTransform(st,backtr); (optional) M*/ @@ -366,13 +368,21 @@ SLEPC_EXTERN PetscErrorCode STCreate_Shell(ST st) st->ops->apply = STApply_Shell; st->ops->applytrans = STApplyTranspose_Shell; +#if defined(PETSC_USE_COMPLEX) st->ops->applyhermtrans = STApplyHermitianTranspose_Shell; +#else + st->ops->applyhermtrans = STApplyTranspose_Shell; +#endif st->ops->backtransform = STBackTransform_Shell; st->ops->destroy = STDestroy_Shell; PetscCall(PetscObjectComposeFunction((PetscObject)st,"STShellSetApply_C",STShellSetApply_Shell)); PetscCall(PetscObjectComposeFunction((PetscObject)st,"STShellSetApplyTranspose_C",STShellSetApplyTranspose_Shell)); +#if defined(PETSC_USE_COMPLEX) PetscCall(PetscObjectComposeFunction((PetscObject)st,"STShellSetApplyHermitianTranspose_C",STShellSetApplyHermitianTranspose_Shell)); +#else + PetscCall(PetscObjectComposeFunction((PetscObject)st,"STShellSetApplyHermitianTranspose_C",STShellSetApplyTranspose_Shell)); +#endif PetscCall(PetscObjectComposeFunction((PetscObject)st,"STShellSetBackTransform_C",STShellSetBackTransform_Shell)); PetscFunctionReturn(PETSC_SUCCESS); } diff --git a/src/sys/classes/st/interface/stfunc.c b/src/sys/classes/st/interface/stfunc.c index 01ed5c64a..f4448d81a 100644 --- a/src/sys/classes/st/interface/stfunc.c +++ b/src/sys/classes/st/interface/stfunc.c @@ -140,7 +140,7 @@ PetscErrorCode STDestroy(ST *st) PetscFunctionBegin; if (!*st) PetscFunctionReturn(PETSC_SUCCESS); PetscValidHeaderSpecific(*st,ST_CLASSID,1); - if (--((PetscObject)(*st))->refct > 0) { *st = NULL; PetscFunctionReturn(PETSC_SUCCESS); } + if (--((PetscObject)*st)->refct > 0) { *st = NULL; PetscFunctionReturn(PETSC_SUCCESS); } PetscCall(STReset(*st)); PetscTryTypeMethod(*st,destroy); PetscCall(KSPDestroy(&(*st)->ksp)); diff --git a/src/sys/classes/st/interface/stset.c b/src/sys/classes/st/interface/stset.c index 54b33e418..74c2d1d55 100644 --- a/src/sys/classes/st/interface/stset.c +++ b/src/sys/classes/st/interface/stset.c @@ -338,7 +338,7 @@ PetscErrorCode STSetTransform(ST st,PetscBool flg) } /*@ - STGetTransform - Gets a flag that that indicates whether the transformed + STGetTransform - Gets a flag that indicates whether the transformed matrices are computed or not. Not Collective diff --git a/src/sys/classes/st/tests/test1.c b/src/sys/classes/st/tests/test1.c index 2d55865f5..b193a2109 100644 --- a/src/sys/classes/st/tests/test1.c +++ b/src/sys/classes/st/tests/test1.c @@ -14,7 +14,9 @@ static char help[] = "Test ST with shell matrices.\n\n"; static PetscErrorCode MatMult_Shell(Mat S,Vec x,Vec y); static PetscErrorCode MatMultTranspose_Shell(Mat S,Vec x,Vec y); +#if defined(PETSC_USE_COMPLEX) static PetscErrorCode MatMultHermitianTranspose_Shell(Mat S,Vec x,Vec y); +#endif static PetscErrorCode MatGetDiagonal_Shell(Mat S,Vec diag); static PetscErrorCode MatDuplicate_Shell(Mat S,MatDuplicateOption op,Mat *M); @@ -29,7 +31,9 @@ static PetscErrorCode MyShellMatCreate(Mat *A,Mat *M) PetscCall(MatCreateShell(comm,PETSC_DECIDE,PETSC_DECIDE,n,n,A,M)); PetscCall(MatShellSetOperation(*M,MATOP_MULT,(void(*)(void))MatMult_Shell)); PetscCall(MatShellSetOperation(*M,MATOP_MULT_TRANSPOSE,(void(*)(void))MatMultTranspose_Shell)); +#if defined(PETSC_USE_COMPLEX) PetscCall(MatShellSetOperation(*M,MATOP_MULT_HERMITIAN_TRANSPOSE,(void(*)(void))MatMultHermitianTranspose_Shell)); +#endif PetscCall(MatShellSetOperation(*M,MATOP_GET_DIAGONAL,(void(*)(void))MatGetDiagonal_Shell)); PetscCall(MatShellSetOperation(*M,MATOP_DUPLICATE,(void(*)(void))MatDuplicate_Shell)); PetscFunctionReturn(PETSC_SUCCESS); @@ -58,7 +62,6 @@ int main(int argc,char **argv) PetscCall(MatCreate(PETSC_COMM_WORLD,&A)); PetscCall(MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,n,n)); PetscCall(MatSetFromOptions(A)); - PetscCall(MatSetUp(A)); PetscCall(MatGetOwnershipRange(A,&Istart,&Iend)); for (i=Istart;i Underlying PetscDevice (choose one of) host cuda hip sycl (PetscDeviceContextSetDevice) - -root_device_context_stream_type: PetscDeviceContext PetscStreamType (choose one of) global_blocking default_blocking global_nonblocking (PetscDeviceContextSetStreamType) + -root_device_context_stream_type: PetscDeviceContext PetscStreamType (choose one of) default nonblocking default_with_barrier nonblocking_with_barrier (PetscDeviceContextSetStreamType) ---------------------------------------- BLAS options: -blas_view: Display number of threads to use for BLAS operations (None)