anpcpp 0.1.0
Analytic Network Process computational library
Loading...
Searching...
No Matches
eigen.hpp
Go to the documentation of this file.
1
6#pragma once
7
8#include <cstddef>
9#include <stdexcept>
10#include <string>
11
12#include "anpcpp/matrix.hpp"
13
14namespace anpcpp {
15
19class ConvergenceError : public std::runtime_error {
20public:
24 explicit ConvergenceError(const std::string& message)
25 : std::runtime_error(message) {}
26};
27
37[[nodiscard]] Matrix harker_fix(const Matrix& mat);
38
44 double error = 1e-10;
46 bool use_harker = false;
48 std::size_t max_iterations = 10000;
49};
50
58 double value = 0.0;
60 std::size_t iterations = 0;
62 bool converged = false;
63};
64
74[[nodiscard]] EigenResult principal_eigen(const Matrix& mat,
75 const EigenOptions& options = {});
76
81[[nodiscard]] Vector principal_eigenvector(const Matrix& mat,
82 const EigenOptions& options = {});
83
88[[nodiscard]] double principal_eigenvalue(const Matrix& mat,
89 const EigenOptions& options = {});
90
91} // namespace anpcpp
Thrown when power iteration fails to converge within max_iterations.
Definition eigen.hpp:19
ConvergenceError(const std::string &message)
Definition eigen.hpp:24
Dense row-major matrix stored in a flat buffer.
Definition matrix.hpp:136
One-dimensional array of doubles with element-wise arithmetic.
Definition matrix.hpp:34
Dense row-major vectors and matrices.
Analytic Network Process computational library.
Definition eigen.hpp:14
Vector principal_eigenvector(const Matrix &mat, const EigenOptions &options={})
Returns the principal eigenvector only.
EigenResult principal_eigen(const Matrix &mat, const EigenOptions &options={})
Power iteration with sum-normalization (pyanp pri_eigen compatible).
Matrix harker_fix(const Matrix &mat)
Applies Harker's fix for incomplete pairwise matrices.
double principal_eigenvalue(const Matrix &mat, const EigenOptions &options={})
Returns the principal eigenvalue only.
Options controlling principal eigen computation.
Definition eigen.hpp:42
double error
Stop when max-norm change between iterates is <= error.
Definition eigen.hpp:44
bool use_harker
Apply harker_fix before iteration when true.
Definition eigen.hpp:46
std::size_t max_iterations
Maximum power-iteration steps (pyanp has no cap).
Definition eigen.hpp:48
Result of principal_eigen.
Definition eigen.hpp:54
bool converged
False if max_iterations reached before convergence.
Definition eigen.hpp:62
Vector vector
Priority vector (components sum to 1).
Definition eigen.hpp:56
std::size_t iterations
Number of iterations performed.
Definition eigen.hpp:60
double value
Dominant eigenvalue estimate.
Definition eigen.hpp:58