为什么编译(c ++ 特征)"错误 C2659:'=':函数作为左操作数"后会出现错误?
Why errors occur after compilation(c++ eigen) “error C2659: '=' : function as left operand”?
x1.real = x;
x1(k-1).imag = h;
A.col(k-1) = x1.imag / h;
我已经用 c++ 编写了一个带有特征库的矩阵运算程序,但错误发生在这些行中。我们应该如何纠正它?多谢!
#include "stdafx.h"
#include "iostream"
#include "Eigen/Dense"
using namespace std;
using namespace Eigen;
void jaccsd(Vector3d z, Matrix3d A, Vector3d x)
{
int m, n,k;
double h;
z = x;
n = 3;
m = 3;
A = MatrixXd::Zero(3, 3);
h = n*0.0001;
for (k = 1; k <= n; k++)
{
Vector3cd x1;
x1.real = x;
x1(k-1).imag = h;
A.col(k-1) = x1.imag / h;
}
}
real
和imag
是Vector3cd
的成员函数而不是数据成员,即你需要写
x1.real() = x;
如果您只想分配x1
的实际部分.你也可以写
x1 = x;
如果还想将虚部设置为零。在您的代码中,虚部将未初始化。
这同样适用于:
A.col(k-1) = x1.imag() / h;
相关文章:
- 错误 C2679:二进制"<<":未找到采用类型 'std::string_view' 的右侧操作数的运算符(或者没有可接受的转换)
- 错误:类型"double()"和"double()"的操作数无效到二进制&quo
- 错误:二进制'operator*' 'float'和'float[0]'类型的操作数无效
- 错误 C2679 二进制"<<":未找到采用类型为 'T' 的右侧操作数的运算符
- 错误:'operator>'不匹配(操作数类型为 'Student' 和 'Student'
- 如何摆脱逗号运算符的这个错误右操作数没有效果( wunsued 值)?
- c++ 错误:二进制"运算符+"类型"矩阵*"和"矩阵*"的操作数无效
- 使用堆栈编译错误的 C++ 反向行没有运算符匹配操作数
- 当我尝试构建此程序时,出现此错误:需要左键作为赋值的左操作数
- 错误:二进制">>":未找到采用类型为"const char [1] 的右操作数的运算符
- C++ 重载:[错误] 与'operator='不匹配(操作数类型为 'String' 和"字符串")
- 错误 C2679:二进制'<<':找不到采用类型 'overloaded-function' 的右侧操作数的运算符(或者没有可接受的转换)
- 我收到一个错误无效的操作数,类型为 const char [42] 和二进制"运算符+"的双倍数
- 错误:与"运算符>>"不匹配(操作数类型为"std::istream
- 错误:C2679 二进制"==":未找到采用类型 'const std::string' 的右侧操作数的运算符(或者没有可接受的转换)
- 错误:与'operator='不匹配(操作数类型为 'PlDrustvo' 和"PlDrustvo")|
- 错误:"->"的基本操作数具有非指针类型"const"
- 使用英特尔线程构建块编译:错误操作数为?:
- 错误:操作数不匹配
- C++错误(操作数类型为"std::string 和 'void")