特征值 - 特征值的平衡矩阵
Eigen - Balancing matrix for eigenvalue
我的经验(像其他人一样:如何使用LAPACK从矩阵对的广义舒尔分解中获得指定的特征向量?(是,当矩阵条件不佳时,从特征向量获得的特征值(我不关心特征向量(几乎不如从numpy,matlab等获得的特征值可靠。
互联网(https://www.mathworks.com/help/matlab/ref/balance.html(表明平衡是解决方案,但我无法弄清楚如何在 Eigen 中做到这一点。 谁能帮忙?
目前,我有一个烦人的两层解决方案,涉及python和C++,我想将所有内容都推到C++中;特征值求解器是唯一阻碍我的部分。
事实证明,这篇关于arxiv的精彩小论文对平衡进行了很好的清晰描述:https://arxiv.org/pdf/1401.5766.pdf。 当我实现这种平衡时,特征值几乎与 numpy 完全一致。 如果特征在获取特征值之前平衡矩阵,那就太好了。
void balance_matrix(const Eigen::MatrixXd &A, Eigen::MatrixXd &Aprime, Eigen::MatrixXd &D) {
// https://arxiv.org/pdf/1401.5766.pdf (Algorithm #3)
const int p = 2;
double beta = 2; // Radix base (2?)
Aprime = A;
D = Eigen::MatrixXd::Identity(A.rows(), A.cols());
bool converged = false;
do {
converged = true;
for (Eigen::Index i = 0; i < A.rows(); ++i) {
double c = Aprime.col(i).lpNorm<p>();
double r = Aprime.row(i).lpNorm<p>();
double s = pow(c, p) + pow(r, p);
double f = 1;
while (c < r / beta) {
c *= beta;
r /= beta;
f *= beta;
}
while (c >= r*beta) {
c /= beta;
r *= beta;
f /= beta;
}
if (pow(c, p) + pow(r, p) < 0.95*s) {
converged = false;
D(i, i) *= f;
Aprime.col(i) *= f;
Aprime.row(i) /= f;
}
}
} while (!converged);
}
相关文章:
- 堆栈问题(平衡表达式问题集)
- 编写了一个C++代码来检查表达式是否具有平衡括号并且我的代码未运行.我已经卡了一天了
- 二叉树结构平衡,使用递归时EXC_BAD_ACCESS
- 我正在尝试制作一个自平衡机器人,但编译时存在错误。我不知道如何解决它
- 迭代器范围的平衡分区,没有LegacyRandomAccessIterator
- 使用堆栈从黑客等级中解决平衡括号检查的错误
- 计算数组的特征值/向量,而不是使用特征 3 计算矩阵
- C++如何在宏调用后平衡括号?
- 签入二叉树的函数是平衡C++
- 检查BST中每个节点的平衡因子并将其存储在节点中
- 我该如何平衡一棵退化的树?C++数据结构
- OpenMP 和不平衡嵌套循环
- 使用 vector 检查表达式中的括号是否平衡
- 如何修复重新平衡时AVL删除操作中的分段错误?
- 平衡括号问题为什么要检查它是否为空?
- 平衡数组索引,同时从左和右对数组求和
- OpenMP C++:并行化 for 循环的负载不平衡
- C++ 查找矩阵的特征值和特征向量
- 可以提示插入到标准::地图导致不平衡的树
- 特征值 - 特征值的平衡矩阵