我正在计算矩阵的bdcsvd,然后像这样计算奇异值之和
std::stringstream ss(mat_str);
int m = 66;
int n = 66;
MatrixXd A(m,n);
for(int i=0; i<m; ++i)
for(int j=0; j<n; ++j)
ss >> A(i,j);
Eigen::BDCSVD<MatrixXd> svd(A,ComputeFullU|ComputeFullV);
auto sum = svd.singularValues().colwise().sum().cast<float>();
cout << "Here is the type of :" << endl << typeid(sum).name() << endl;
总和的类型显示为N5Eigen12CwiseUnaryOpINS_8internal14scalar_cast_opIdfEEKNS_16PartialReduxExprIKNS_6MatrixIdLin1ELi1ELi0ELin1ELi1EEENS1_10member_sumIdEELi0EEEEE
而不是float。如何将总和转换/转换为浮点数?