Lagrange
Loading...
Searching...
No Matches
eigen_solvers.h
1/*
2 * Copyright 2025 Adobe. All rights reserved.
3 * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License. You may obtain a copy
5 * of the License at http://www.apache.org/licenses/LICENSE-2.0
6 *
7 * Unless required by applicable law or agreed to in writing, software distributed under
8 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9 * OF ANY KIND, either express or implied. See the License for the specific language
10 * governing permissions and limitations under the License.
11 */
12#pragma once
13
14#include <Eigen/Core>
15#include <Eigen/Sparse>
16
17namespace lagrange::solver {
18
22enum class Status { Successful, NotComputed, NotConverging, NumericalIssue };
23
29template <typename Scalar>
31{
33 Eigen::Matrix<Scalar, Eigen::Dynamic, 1> eigenvalues;
34
36 Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> eigenvectors;
37
39 size_t num_converged = 0;
40
42 Status info = Status::NotComputed;
43
45 bool is_successful() const { return info == Status::Successful; }
46};
47
60template <typename Scalar>
61EigenResult<Scalar> selfadjoint_eigen_largest(const Eigen::SparseMatrix<Scalar>& A, size_t k);
62
76template <typename Scalar>
77EigenResult<Scalar> selfadjoint_eigen_smallest(const Eigen::SparseMatrix<Scalar>& A, size_t k);
78
96template <typename Scalar>
97EigenResult<Scalar> generalized_selfadjoint_eigen_largest(
98 const Eigen::SparseMatrix<Scalar>& A,
99 const Eigen::SparseMatrix<Scalar>& M,
100 size_t k);
101
120template <typename Scalar>
121EigenResult<Scalar> generalized_selfadjoint_eigen_smallest(
122 const Eigen::SparseMatrix<Scalar>& A,
123 const Eigen::SparseMatrix<Scalar>& M,
124 size_t k);
125
126} // namespace lagrange::solver
Result structure for eigenvalue computations.
Definition eigen_solvers.h:31
size_t num_converged
Number of converged eigenvalues.
Definition eigen_solvers.h:39
Status info
Computation status.
Definition eigen_solvers.h:42
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > eigenvalues
Computed eigenvalues.
Definition eigen_solvers.h:33
bool is_successful() const
Check if the computation was successful.
Definition eigen_solvers.h:45
Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > eigenvectors
Computed eigenvectors (column-wise).
Definition eigen_solvers.h:36