Skip to content
Snippets Groups Projects
Select Git revision
  • 1dcf50f0e6d6c8a9dc8a5de1590f5237b05c866b
  • develop default protected
  • feature/variational-hydro
  • origin/stage/bouguettaia
  • feature/gmsh-reader
  • feature/reconstruction
  • save_clemence
  • feature/kinetic-schemes
  • feature/local-dt-fsi
  • feature/composite-scheme-sources
  • feature/composite-scheme-other-fluxes
  • feature/serraille
  • feature/composite-scheme
  • hyperplastic
  • feature/polynomials
  • feature/gks
  • feature/implicit-solver-o2
  • feature/coupling_module
  • feature/implicit-solver
  • feature/merge-local-dt-fsi
  • master protected
  • v0.5.0 protected
  • v0.4.1 protected
  • v0.4.0 protected
  • v0.3.0 protected
  • v0.2.0 protected
  • v0.1.0 protected
  • Kidder
  • v0.0.4 protected
  • v0.0.3 protected
  • v0.0.2 protected
  • v0 protected
  • v0.0.1 protected
33 results

EigenvalueSolver.hpp

Blame
  • EigenvalueSolver.hpp 3.72 KiB
    #ifndef EIGENVALUE_SOLVER_HPP
    #define EIGENVALUE_SOLVER_HPP
    
    #include <algebra/EigenvalueSolverOptions.hpp>
    
    #include <algebra/CRSMatrix.hpp>
    #include <algebra/DenseMatrixWrapper.hpp>
    #include <algebra/SmallMatrix.hpp>
    #include <algebra/SmallVector.hpp>
    #include <algebra/TinyMatrix.hpp>
    #include <utils/Exceptions.hpp>
    #include <utils/SmallArray.hpp>
    
    class EigenvalueSolver
    {
     private:
      struct Internals;
    
      const EigenvalueSolverOptions m_options;
    
      void _slepscComputeForSymmetricMatrix(const CRSMatrix<double>& A, SmallArray<double>& eigenvalues);
    
      void _slepscComputeForSymmetricMatrix(const DenseMatrixWrapper<double>& A, SmallArray<double>& eigenvalues);
    
      void _slepscComputeForSymmetricMatrix(const CRSMatrix<double>& A,
                                            SmallArray<double>& eigenvalues,
                                            std::vector<SmallVector<double>>& eigenvectors);
    
      void _slepscComputeForSymmetricMatrix(const DenseMatrixWrapper<double>& A,
                                            SmallArray<double>& eigenvalues,
                                            std::vector<SmallVector<double>>& eigenvectors);
    
      void _slepscComputeForSymmetricMatrix(const CRSMatrix<double>& A,
                                            SmallArray<double>& eigenvalues,
                                            SmallMatrix<double>& P);
    
      void _slepscComputeForSymmetricMatrix(const DenseMatrixWrapper<double>& A,
                                            SmallArray<double>& eigenvalues,
                                            SmallMatrix<double>& P);
    
     public:
      static bool hasLibrary(ESLibrary library);
      static void checkHasLibrary(const ESLibrary library);
    
      template <typename MatrixType>
      void
      computeForSymmetricMatrix(const MatrixType& A, SmallArray<double>& eigenvalues)
      {
        Assert((eigenvalues.size() - A.numberOfRows() == 0) and A.isSquare());
    
        switch (m_options.library()) {
        case ESLibrary::eigen3: {
          throw NotImplementedError("Eigen3");
        }
        case ESLibrary::slepsc: {
          this->_slepscComputeForSymmetricMatrix(A, eigenvalues);
          break;
        }
        default: {
          throw UnexpectedError(::name(m_options.library()) + " cannot compute for symmetric matrices");
        }
        }
      }
    
      template <typename MatrixType>
      void
      computeForSymmetricMatrix(const MatrixType& A,
                                SmallArray<double>& eigenvalues,
                                std::vector<SmallVector<double>>& eigenvectors)
      {
        Assert((eigenvalues.size() - A.numberOfRows() == 0) and (A.numberOfRows() - eigenvectors.size() == 0) and
               A.isSquare());
    
        switch (m_options.library()) {
        case ESLibrary::eigen3: {
          throw NotImplementedError("Eigen3");
        }
        case ESLibrary::slepsc: {
          this->_slepscComputeForSymmetricMatrix(A, eigenvalues, eigenvectors);
          break;
        }
        default: {
          throw UnexpectedError(::name(m_options.library()) + " cannot compute for symmetric matrices");
        }
        }
      }
    
      template <typename MatrixType>
      void
      computeForSymmetricMatrix(const MatrixType& A, SmallArray<double>& eigenvalues, SmallMatrix<double>& P)
      {
        Assert((eigenvalues.size() - A.numberOfRows() == 0) and (A.numberOfRows() - P.numberOfRows() == 0) and
               A.isSquare() and P.isSquare());
    
        switch (m_options.library()) {
        case ESLibrary::eigen3: {
          throw NotImplementedError("Eigen3");
        }
        case ESLibrary::slepsc: {
          this->_slepscComputeForSymmetricMatrix(A, eigenvalues, P);
          break;
        }
        default: {
          throw UnexpectedError(::name(m_options.library()) + " cannot compute for symmetric matrices");
        }
        }
      }
    
      EigenvalueSolver(const EigenvalueSolverOptions& options = EigenvalueSolverOptions::default_options);
      ~EigenvalueSolver() = default;
    };
    
    #endif   // EIGENVALUE_SOLVER_HPP