Eigen:访问ProductBase系数
Eigen: Accessing ProductBase coefficients
以下代码片段死于特征断言:
MatrixXd L;
VectorXd x, b;
...
ASSERT_MATRIX_EQ(L*x, b);
带,
template <typename DerivedL, typename DerivedR>
void ASSERT_MATRIX_EQ(const Eigen::DenseBase<DerivedL>& A, const Eigen::DenseBase<DerivedR>& B, double tol=1e-7) {
ASSERT_EQ(A.rows(), B.rows());
ASSERT_EQ(A.cols(), B.cols());
for(int i=0; i < A.rows(); i++) {
for(int j=0; j < A.cols(); j++) {
ASSERT_NEAR(A(i,j), B(i,j), tol);
}
}
}
它死于错误:
test_leq: /usr/include/eigen3/Eigen/src/Core/ProductBase.h:154: typename Base::CoeffReturnType Eigen::ProductBase<Eigen::GeneralProduct<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, 4>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >::coeff(Index, Index) const: Assertion `this->rows() == 1 && this->cols() == 1' failed.
在对CCD_ 1的调用中。(不过,我可以呼叫cout << A << endl;
。)
在154线上,ProductBase.h
奇怪地具有断言
// restrict coeff accessors to 1x1 expressions. No need to care about mutators here since this isnt a Lvalue expression
typename Base::CoeffReturnType coeff(Index row, Index col) const
{
#ifdef EIGEN2_SUPPORT
return lhs().row(row).cwiseProduct(rhs().col(col).transpose()).sum();
#else
EIGEN_STATIC_ASSERT_SIZE_1x1(Derived)
eigen_assert(this->rows() == 1 && this->cols() == 1);
return derived().coeff(row,col);
#endif
}
我遵循Eigen编写通用矩阵函数的指南。如何正确编写此泛型函数?
编辑:也很高兴知道为什么ProductBase
期望1x1矩阵。
Eigen邮件列表上的线程表示有意禁用ProductBase
上的系数访问。目前的解决方案是避免使用foobar(A*x)
这样的表达式。
相关文章:
- 有没有办法找到特征矩阵系数的中值?
- 特征稀疏向量:求最大系数
- 将系数存储在头文件的数组中("does not name a type"错误)
- 改变或缩放两个正态分布以具有特定的相关系数
- 如何更改古罗比C++模型中的目标值系数
- 如何设置vtk相机的正确变焦系数?
- 稳定的婚姻问题幸福系数
- 如何改进搜索二项式系数的递归算法
- 两个二项式系数模 10^9 + 7 的 GCD
- HALCON到OpenCV失真系数的转换
- 多项式系数代码始终提供相同的答案
- ONVIF-获取放大系数
- 如何在返回向量中访问系数
- 用Isringstream C 提取多项式的系数
- 编码域中的DCT系数和运动矢量提取
- 使用动态编程计算二项式系数
- 使用某些系数将图像转换为灰度的最快方法
- std::regex来识别多项式方程的系数
- 二项式系数程序输出错误的结果,如果输入是大的(C++)
- Eigen:访问ProductBase系数