Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ c+中带有模板/宏语法的typdef+;_C++_Templates_Eigen - Fatal编程技术网

C++ c+中带有模板/宏语法的typdef+;

C++ c+中带有模板/宏语法的typdef+;,c++,templates,eigen,C++,Templates,Eigen,我使用的是特征值库,我只是尝试在解后打印文件中的特征值。虽然结果相当简单,但由于返回类类型的复杂性,除了一组存储在vector中的浮点数,我无法将它们转换为可转换代码,或者我不知道是否存在任何内在函数 typedef CwiseBinaryOp<internal::scalar_quotient_op<ComplexScalar,Scalar>, ComplexVectorType,VectorType> EigenvalueType; 如果我看一下特征值类型定义,它就

我使用的是特征值库,我只是尝试在解后打印文件中的特征值。虽然结果相当简单,但由于返回类类型的复杂性,除了一组存储在vector中的浮点数,我无法将它们转换为可转换代码,或者我不知道是否存在任何内在函数

typedef CwiseBinaryOp<internal::scalar_quotient_op<ComplexScalar,Scalar>,
ComplexVectorType,VectorType> EigenvalueType;
如果我看一下特征值类型定义,它就是特征值类型:
typedef CwiseBinaryOp特征值类型这对我没有任何提示


如何将该类类型转换为浮点值

说明“前提条件:构造函数GeneralizedEigenSolver(const MatrixType&,const MatrixType&,bool)或成员函数compute(const MatrixType&,const MatrixType&,bool)之前已被调用。”也许你忘了这么做?既然你已经知道写入流(
cout
)是有效的,为什么不使用
fstream
)呢?@nwp不,它解决的问题解决方案没有任何问题,检索正确的值并在控制台屏幕上正确打印它们,在试图打印出值
ges.Solve(A,B)之前,我已经读取了声明的
GeneralizedEigenSolver ges
,并调用了它。差异是当我试图将它们写入一个文件时,该行
fprintf出现语法问题(文件在“特征值为:%f”,ges.featurevalues()中)我不明白。@AlanStokes,如果这是一个证明<代码>可以<代码>工作的证据,并且可以使用fstream,那么它是一个很好的切入点,使用fopen完全是我自己对IO处理的喜好,我会尝试一下。但在任何情况下,声明
typedef CwiseBinaryOp特征值类型在我看来并不清楚,我在谷歌上搜索了typdef模板,但那里没有多少明确的帮助。通常情况下,您不需要了解这种类型是如何定义的(这被认为是一个实现细节)——相反,文档应该指定您可以使用它做什么。向steam写入数据得到了明确支持;转换为简单浮点或双精度可能是(或者,如果有意义的话,您可以迭代这些值)。
cout << "The (complex) numerators of the generalzied eigenvalues are: " << ges.alphas().transpose() << endl;
cout << "The (real) denominatore of the generalzied eigenvalues are: " << ges.betas().transpose() << endl;
cout << "The (complex) generalized eigenvalues are (alphas./beta): " << ges.eigenvalues().transpose() << endl;
file_in = fopen("result.txt","w");
if (file_in!=NULL )
{
    fprintf(file_in,"aasd");
    fprintf(file_in,"Eigen values are : %f",ges.eigenvalues());
}
fclose(file_in);