在 EIGEN 中,c++ 不能将向量乘以它的转置
In EIGEN c++ cannot multiply vector by it's transpose
在执行下面的代码时,我得到了这个错误:" invalid_vector_vector_product_if_you_wanted_a_dot_or_coeff_wise_product_you_must_use_the_explicit_functions "
#include <iostream>
#include <Eigen/Dense>
using namespace Eigen;
int main()
{
Vector3d v(1, 2, 3);
Vector3d vT = v.transpose();
Matrix3d ans = v*vT;
std::cout << ans << std::endl;
}
Vector3d
定义为列向量,因此v
和vT
都是列向量。因此,操作v*vT
没有意义。你要做的是
Matrix3d ans = v*v.transpose();
或将vT
定义为RowVector3d
Vector3d v(1, 2, 3);
RowVector3d vT = v.transpose();
Matrix3d ans = v*vT;
相关文章:
- 转置矩阵:交换元素不会更改值
- 使用 Eigen 3 库编写一个带有转置作为参数的函数
- 犰狳(C++)中的快速阵列置换(广义张量转置)
- 为什么转置这个 std::vector<std::vector<std::string> > 这么慢?
- 转置结构容器
- 我的转置矩阵代码有什么问题?
- 是否可以在不指定类型的情况下从 istringstream 转到向量?
- 数组的转置和乘法
- 在C++中使用矢量转置 2D 矩阵
- 特征:块转置
- MKL矩形矩阵Inplace转置:不使用多个核心
- 并行转置不同的矩阵
- 关于次级对角线的转置(翻转)矩阵
- 输出是从您输入的矩阵中打印出矩阵的转置,但我的代码只是打印出您输入的第一个矩阵
- 如何在阵列火中避免翻转和转置的memcpy?
- CUDA矩阵与共享内存转置
- C 阵列的复合物共轭转置
- 转置期间的动态内存分配
- 转置的一维矢量的平均矢量
- 在 EIGEN 中,c++ 不能将向量乘以它的转置