### Check SLEPc Installation Source: https://gitlab.com/slepc/slepc/-/blob/main/doc/source/installation/quickstart.md Runs test examples to verify a smooth installation. Examine the output for any errors. ```console $ make check ``` -------------------------------- ### Install Miniforge Source: https://gitlab.com/slepc/slepc/-/blob/main/doc/source/documentation/faq.md Install Miniforge in the user's home directory. This command executes the downloaded installer script with batch mode and specifies the installation path. ```console $ bash Miniforge3-Linux-x86_64.sh -b -p ~/miniforge ``` -------------------------------- ### Compiling the Example Source: https://gitlab.com/slepc/slepc/-/blob/main/doc/source/documentation/hands-on/hands-on8.md Command to build the executable for the quadratic eigenvalue problem solver example. ```console $ make ex16 ``` -------------------------------- ### SLEPc Prefix-based Installation with PETSc Source: https://gitlab.com/slepc/slepc/-/blob/main/doc/source/documentation/manual/intro.md Prepare a prefix-based SLEPc installation by setting PETSC_DIR, unsetting PETSC_ARCH, configuring SLEPc with a prefix, and then building and installing. ```bash export PETSC_DIR=/opt/petsc-{{env.config.release}}-linux-gnu-c-debug unset PETSC_ARCH cd $SLEPC_DIR ./configure --prefix=/opt/slepc-{{env.config.release}}-linux-gnu-c-debug make make install export SLEPC_DIR=/opt/slepc-{{env.config.release}}-linux-gnu-c-debug ``` -------------------------------- ### Install SLEPc Source: https://gitlab.com/slepc/slepc/-/blob/main/doc/source/installation/quickstart.md Installs SLEPc if an installation directory was specified during configuration using the --prefix option. Useful for building as a regular user. ```console $ make install ``` -------------------------------- ### Command-line Example: Sequential Solves with Partitions Source: https://gitlab.com/slepc/slepc/-/blob/main/doc/source/documentation/manual/st.md Example demonstrating parallel spectrum slicing using sequential linear solves by setting the number of partitions equal to the number of MPI processes. This configuration uses 4 partitions, each with one process. ```console $ mpiexec -n 4 ./ex25 -eps_interval 0.4,0.8 -eps_krylovschur_partitions 4 -st_type sinvert -st_ksp_type preonly -st_pc_type cholesky ``` -------------------------------- ### Install SLEPc from Source Source: https://context7.com/slepc/slepc/llms.txt Set environment variables for PETSc and SLEPc directories, then unpack, configure, build, and test SLEPc. Optional configurations include external packages like ARPACK, Python bindings, or a prefix-based install. ```bash # Set environment variables export PETSC_DIR=/home/user/petsc-3.25 export PETSC_ARCH=arch-linux-gnu-c-debug export SLEPC_DIR=/home/user/slepc-3.25 # Unpack, configure, build and test tar xzf slepc-3.25.tar.gz cd slepc-3.25 ./configure make make check # With optional external packages (e.g., ARPACK) ./configure --with-arpack-dir=/usr/software/ARPACK # With Python bindings (slepc4py) ./configure --with-slepc4py # Prefix-based install ./configure --prefix=/opt/slepc-3.25 make && make install # Run a parallel job (8 MPI processes) mpiexec -n 8 ./my_slepc_program -eps_nev 10 ``` -------------------------------- ### Compile SLEPc Example Source: https://gitlab.com/slepc/slepc/-/blob/main/doc/source/documentation/hands-on/hands-on3.md Instructions for compiling the ex7.c example program using a makefile. Ensure SLEPC_EPS_LIB and CLINKER are correctly set. ```makefile ex7: ex7.o -${CLINKER} -o ex7 ex7.o ${SLEPC_EPS_LIB} ${RM} ex7.o ``` -------------------------------- ### Command-line Example: Parallel Solves with MUMPS Source: https://gitlab.com/slepc/slepc/-/blob/main/doc/source/documentation/manual/st.md Example of parallel spectrum slicing using the MUMPS direct solver. This configuration uses 4 partitions and 20 MPI processes in total, with 5 processes per partition. ```console $ mpiexec -n 20 ./ex25 -eps_interval 0.4,0.8 -eps_krylovschur_partitions 4 -st_type sinvert -st_ksp_type preonly -st_pc_type cholesky -st_pc_factor_mat_solver_type mumps -st_mat_mumps_icntl_13 1 ``` -------------------------------- ### PEP Solver Command-Line Options Example Source: https://gitlab.com/slepc/slepc/-/blob/main/doc/source/documentation/hands-on/hands-on8.md Example of how to modify the behavior of the PEP solver using command-line arguments to request more eigenvalues, increase the basis vector size, select smallest magnitude eigenvalues, and set a different tolerance. ```console $ ./ex16 -pep_nev 4 -pep_ncv 24 -pep_smallest_magnitude -pep_tol 1e-5 ``` -------------------------------- ### Install SLEPc with zypper (openSUSE) Source: https://gitlab.com/slepc/slepc/-/blob/main/doc/source/installation/index.md Install SLEPc using the zypper package manager on openSUSE. ```bash sudo zypper install slepc ``` -------------------------------- ### Download Miniforge Installer Source: https://gitlab.com/slepc/slepc/-/blob/main/doc/source/documentation/faq.md Download the Miniforge installer script for Linux x86_64. This is the first step in setting up a conda environment for installing slepc4py with complex scalars. ```console $ wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh ``` -------------------------------- ### Example Output Source: https://gitlab.com/slepc/slepc/-/blob/main/doc/source/documentation/hands-on/hands-on1.md Sample output from running the 1-D Laplacian Eigenproblem solver, showing iteration count, convergence, and computed eigenvalues. ```text 1-D Laplacian Eigenproblem, n=50 Number of iterations of the method: 8 Solution method: krylovschur Number of requested eigenvalues: 1 Stopping condition: tol=1e-08, maxit=100 Number of converged eigenpairs: 3 k ||Ax-kx|| ----------------- ------------------ 3.996207 4.30363e-10 3.984841 2.08631e-09 3.965946 9.98404e-09 ``` -------------------------------- ### Install NumPy and petsc4py using pip Source: https://gitlab.com/slepc/slepc/-/blob/main/src/binding/slepc4py/docs/source/install.rst Ensure you have NumPy and petsc4py installed before proceeding with slepc4py installation. ```bash $ python -m pip install numpy petsc petsc4py ``` -------------------------------- ### Makefile for PEP Solver Example Source: https://gitlab.com/slepc/slepc/-/blob/main/doc/source/documentation/hands-on/hands-on8.md This snippet shows the necessary lines to add to a Makefile for compiling the ex16.c example for PEP solvers. ```makefile ex16: ex16.o -${CLINKER} -o ex16 ex16.o ${SLEPC_PEP_LIB} ${RM} ex16.o ``` -------------------------------- ### Configure SLEPc Installation Source: https://gitlab.com/slepc/slepc/-/blob/main/doc/source/documentation/manual/intro.md Run the configure script from the SLEPc directory to set up the build environment. This step should be performed after setting environment variables. ```console $ cd $SLEPC_DIR $ ./configure ``` -------------------------------- ### Compile Example 11 Source: https://gitlab.com/slepc/slepc/-/blob/main/doc/source/documentation/hands-on/hands-on7.md Add these lines to your makefile to compile the ex11 executable. Ensure SLEPC_EPS_LIB is correctly set. ```makefile ex11: ex11.o -${CLINKER} -o ex11 ex11.o ${SLEPC_EPS_LIB} ${RM} ex11.o ``` -------------------------------- ### Install First PETSc Configuration Source: https://gitlab.com/slepc/slepc/-/blob/main/doc/source/documentation/manual/intro.md Set PETSC_ARCH and configure PETSc for a real scalar type. This creates a subdirectory for this specific configuration. ```console $ cd $PETSC_DIR $ export PETSC_ARCH=arch-linux-gnu-c-debug-real $ ./configure --with-scalar-type=real $ make all ``` -------------------------------- ### Compile Executable with Make Source: https://gitlab.com/slepc/slepc/-/blob/main/doc/source/documentation/hands-on/hands-on1.md Use this makefile snippet to compile the C example. Ensure SLEPc libraries are correctly linked. ```makefile ex1: ex1.o -${CLINKER} -o ex1 ex1.o ${SLEPC_EPS_LIB} ${RM} ex1.o ``` -------------------------------- ### Command Line Example for Harmonic Extraction Source: https://gitlab.com/slepc/slepc/-/blob/main/doc/source/documentation/manual/eps.md This command-line example demonstrates how to compute eigenvalues closest to a target value (0.8) for a real non-symmetric matrix. It also shows how to increase the number of non-symmetric Krylov dimensions (ncv) for potentially better convergence of interior eigenvalues. ```console $ ./ex5 -m 45 -eps_harmonic -eps_target 0.8 -eps_ncv 60 ``` -------------------------------- ### Install SLEPc and PETSc for Python (Development) Source: https://gitlab.com/slepc/slepc/-/blob/main/doc/source/installation/index.md Install SLEPc and PETSc from their GitLab archives for development purposes, including necessary build tools and Python packages. ```bash python -m pip install Cython numpy mpi4py ``` ```bash python -m pip install --no-deps https://gitlab.com/petsc/petsc/-/archive/main/petsc-main.tar.gz ``` ```bash python -m pip install --no-deps https://gitlab.com/slepc/slepc/-/archive/main/slepc-main.tar.gz ``` -------------------------------- ### Install SLEPc with apt (Debian/Ubuntu) Source: https://gitlab.com/slepc/slepc/-/blob/main/doc/source/installation/index.md Install the SLEPc development package using apt on Debian or Ubuntu systems. ```bash sudo apt install slepc-dev ``` -------------------------------- ### Install SLEPc and PETSc for Python (Release) Source: https://gitlab.com/slepc/slepc/-/blob/main/doc/source/installation/index.md Install SLEPc and its Python bindings (slepc4py) along with necessary dependencies like numpy, mpi4py, and PETSc. ```bash python -m pip install numpy mpi4py ``` ```bash python -m pip install petsc petsc4py ``` ```bash python -m pip install slepc slepc4py ``` -------------------------------- ### Install slepc4py from SLEPc source tree Source: https://gitlab.com/slepc/slepc/-/blob/main/src/binding/slepc4py/docs/source/install.rst Install slepc4py from the SLEPc source tree by navigating to the top of the SLEPc source directory and running pip. ```bash $ python -m pip install src/binding/slepc4py ``` -------------------------------- ### Fortran Example for Eigenvalue Problem Source: https://gitlab.com/slepc/slepc/-/blob/main/doc/source/documentation/manual/extra.md This is the Fortran equivalent of a simple example for solving eigenvalue problems. It requires including SLEPc header files. ```fortran #include ! ! This example is the Fortran equivalent of the C example ex1.c ! program main implicit none PetscErrorCode ierr PetscInt n, m, nmax, k PetscScalar ar(3,3), ai(3,3), br(3,3), bi(3,3) PetscScalar *ritz, *crritz PetscReal tol EPS eps EPSType type char filename(PETSC_MAX_PATH_LEN) PetscBool flg call SlepcInitialize(PETSC_NULL_CHARACTER, PETSC_NULL_CHARACTER, PETSC_NULL_CHARACTER, PETSC_NULL_CHARACTER, ierr) ierr = PetscOptionsGetInt(PETSC_NULL_HANDLE, '-n', n, flg, ierr) if (.not. flg) n = 3 nmax = n k = 1 if (n .gt. 3) k = 2 if (n .gt. 10) k = 3 ierr = EPSCreate(PETSC_COMM_WORLD, eps, ierr) ierr = EPSSetType(eps, EPSKRYLOV, ierr) ierr = EPSKrylovSetDimensions(eps, nmax, k, ierr) ierr = EPSSetWhichEigenpairs(eps, EPS_SMALLEST_REAL, ierr) ierr = EPSGetDimensions(eps, nmax, k, ierr) ierr = EPSGetTolerances(eps, tol, PETSC_NULL_INTEGER, ierr) ierr = EPSGetKrylovSubspaceDimension(eps, nmax, ierr) ierr = EPSSetFromOptions(eps, ierr) ! Construct the matrices A and B call ex1f_matrices(n, ar, ai, br, bi, ierr) ierr = EPSSetOperators(eps, n, ar, ai, br, bi, ierr) ierr = EPSPSetFromOptions(eps, ierr) ierr = EPSSolve(eps, ierr) ierr = EPSGetType(eps, type, ierr) ierr = PetscPrintf(PETSC_COMM_WORLD, 'Solution method: %s\n', type, ierr) ierr = EPSGetNumberEigenvalues(eps, n, ierr) ierr = PetscPrintf(PETSC_COMM_WORLD, 'Number of eigenvalues found: %D\n', n, ierr) ierr = PetscMalloc(n*sizeof(PetscScalar), ritz, ierr) ierr = PetscMalloc(n*sizeof(PetscScalar), crritz, ierr) ierr = EPSGetEigenvalues(eps, ritz, crritz, ierr) ierr = EPSIsGeneralized(eps, flg, ierr) if (flg) then ierr = PetscPrintf(PETSC_COMM_WORLD, '\nGeneralized Eigenvalue Problem:\n', ierr) else ierr = PetscPrintf(PETSC_COMM_WORLD, '\nStandard Eigenvalue Problem:\n', ierr) endif do i = 1, n ierr = PetscScalarPrint(ritz(i), PETSC_PRINT_STYLE_DEFAULT, ierr) if (crritz(i) .ne. 0.0) then ierr = PetscScalarPrint(crritz(i), PETSC_PRINT_STYLE_DEFAULT, ierr) endif ierr = PetscPrintf(PETSC_COMM_WORLD, '\n', ierr) end do ierr = EPSDestroy(eps, ierr) ierr = SlepcFinalize(ierr) stop end program main subroutine ex1f_matrices(n, ar, ai, br, bi, ierr) implicit none use petscts, only: PetscScalar, PETSC_COMM_WORLD use slepc, only: EPS integer, intent(in) :: n PetscScalar, intent(out) :: ar(3,3), ai(3,3), br(3,3), bi(3,3) PetscErrorCode ierr integer :: i, j do i = 1, n do j = 1, n ar(i,j) = 0.0 ai(i,j) = 0.0 br(i,j) = 0.0 bi(i,j) = 0.0 end do end do do i = 1, n ar(i,i) = -2.0 br(i,i) = 1.0 if (i .gt. 1) then ar(i-1,i) = 1.0 ar(i,i-1) = 1.0 br(i-1,i) = -0.5 br(i,i-1) = -0.5 end if end do end subroutine ex1f_matrices ``` -------------------------------- ### Install mpi4py using pip Source: https://gitlab.com/slepc/slepc/-/blob/main/src/binding/slepc4py/docs/source/install.rst Install mpi4py first if you have a working MPI implementation and the 'mpicc' compiler wrapper is on your search path. ```bash $ python -m pip install mpi4py ``` -------------------------------- ### Configure SLEPc Installation Source: https://gitlab.com/slepc/slepc/-/blob/main/doc/source/installation/quickstart.md Runs the configure script in the SLEPc directory. Use --help for available options, especially for enabling external packages. ```console $ ./configure ``` -------------------------------- ### Run with Debugger Source: https://gitlab.com/slepc/slepc/-/blob/main/doc/source/documentation/hands-on/hands-on0.md Execute a program with debugging support enabled. This will start the program in a debugger, stopped at the SlepcInitialize() function. ```console ./hello -start_in_debugger ``` -------------------------------- ### Compile SVD executable Source: https://gitlab.com/slepc/slepc/-/blob/main/doc/source/documentation/hands-on/hands-on4.md Add these lines to your makefile to compile the SVD example program. Ensure SLEPC_SVD_LIB is correctly set. ```make ex14: ex14.o -${CLINKER} -o ex14 ex14.o ${SLEPC_SVD_LIB} ${RM} ex14.o ``` -------------------------------- ### Makefile for Matrix-Free Example Source: https://gitlab.com/slepc/slepc/-/blob/main/doc/source/documentation/hands-on/hands-on5.md This makefile snippet shows how to link the object file with SLEPc libraries to create an executable for a matrix-free problem. ```makefile ex3: ex3.o -${CLINKER} -o ex3 ex3.o ${SLEPC_EPS_LIB} ${RM} ex3.o ``` -------------------------------- ### Visualize Eigenvalues with Plotting Source: https://gitlab.com/slepc/slepc/-/blob/main/doc/source/documentation/hands-on/hands-on3.md Run the ex7 program to compute multiple eigenpairs and visualize them using the 'draw' option. Requires X11 display setup. ```console ./ex7 -f1 ${SLEPC_DIR}/share/slepc/datafiles/matrices/bfw62a.petsc -f2 ${SLEPC_DIR}/share/slepc/datafiles/matrices/bfw62b.petsc -eps_type subspace -eps_nev 6 -eps_view_values draw -draw_pause -1 ``` -------------------------------- ### Check Spack Installation Specification Source: https://gitlab.com/slepc/slepc/-/blob/main/doc/source/documentation/faq.md Check the exact specification for installing py-slepc4py with PETSc complex scalars using spack. This command shows what packages and variants will be installed without actually performing the installation. ```console $ spack spec py-slepc4py ^petsc+complex ``` -------------------------------- ### Running the Program and Sample Output Source: https://gitlab.com/slepc/slepc/-/blob/main/doc/source/documentation/hands-on/hands-on8.md Demonstrates how to run the compiled program without arguments and displays a sample of the expected output, showing converged eigenvalues and their associated norms. ```console Quadratic Eigenproblem, N=100 (10x10 grid) Number of requested eigenvalues: 1 k ||P(k)x||/||kx|| ----------------- ------------------ -1.164037+1.653625i 2.02021e-12 -1.164037-1.653625i 2.02021e-12 ``` -------------------------------- ### Set environment variables for pip installation Source: https://gitlab.com/slepc/slepc/-/blob/main/src/binding/slepc4py/docs/source/install.rst If you have existing PETSc and SLEPc installations, set the SLEPC_DIR and PETSC_DIR environment variables (and PETSC_ARCH if necessary) before installing via pip. ```bash $ export SLEPC_DIR=/path/to/slepc $ export PETSC_DIR=/path/to/petsc $ export PETSC_ARCH=arch-linux2-c-opt $ python -m pip install petsc4py slepc4py ``` -------------------------------- ### Install slepc4py using pip Source: https://gitlab.com/slepc/slepc/-/blob/main/src/binding/slepc4py/docs/source/install.rst Install slepc4py from PyPI after its dependencies are met. ```bash $ python -m pip install slepc slepc4py ``` -------------------------------- ### Install SLEPc with MacPorts Source: https://gitlab.com/slepc/slepc/-/blob/main/doc/source/installation/index.md Install SLEPc using the MacPorts package manager. ```bash sudo port install slepc ``` -------------------------------- ### Install SLEPc with Homebrew Source: https://gitlab.com/slepc/slepc/-/blob/main/doc/source/installation/index.md Install SLEPc using the Homebrew package manager on macOS. ```bash brew install slepc ``` -------------------------------- ### Basic SVD Solver Usage in C Source: https://gitlab.com/slepc/slepc/-/blob/main/doc/source/documentation/manual/svd.md This example demonstrates the fundamental steps for computing a singular value decomposition using the SLEPc SVD package. It covers creating the solver context, setting the problem matrix and type, invoking the solver, retrieving converged solutions, and cleaning up resources. ```c SVD svd; /* SVD solver context */ Mat A; /* problem matrix */ Vec u, v; /* singular vectors */ PetscReal sigma; /* singular value */ PetscInt j, nconv; PetscReal error; SVDCreate(PETSC_COMM_WORLD, &svd); SVDSetOperators(svd, A, NULL); SVDSetProblemType(svd, SVD_STANDARD); SVDSetFromOptions(svd); SVDSolve(svd); SVDGetConverged(svd, &nconv); for (j=0;j