gpt4 book ai didi

c++ - Armadillo 复杂矩阵乘法早期近似

转载 作者:行者123 更新时间:2023-11-30 03:54:21 32 4
gpt4 key购买 nike

如何提高 Armadillo 复杂矩阵乘法结果的精度。它近似于小数点后 4 位 [这是结果的一个示例 (35.9682,-150.246) ] 但我想要至少 8 位小数的精度。谢谢

最佳答案

因为你似乎不相信我在评论中说的话:

#include <armadillo>

using namespace std;
using namespace arma;

int main(int argc, char** argv) {
mat A = randu<mat>(4,5);
mat B = randu<mat>(4,5);

mat C = A*B.t();
cout << C << endl;

cout.precision(11);
cout.setf(ios::fixed);
C.raw_print(cout, "With increased precisions:");

return 0;
}

如预期的那样:

edd@max:/tmp$ g++ -o eze eze.cpp -larmadillo -lblas -llapack 
edd@max:/tmp$ ./eze
0.9713 1.3566 0.7946 1.6896
1.2593 1.1457 0.9011 1.6260
1.1954 0.8484 1.0444 1.6753
1.6225 1.5009 1.2935 2.2019

With increased precisions:
0.97126557882 1.35660885673 0.79462856896 1.68955180769
1.25933041551 1.14565671740 0.90105251304 1.62595390611
1.19543745264 0.84844286454 1.04436441020 1.67528315350
1.62246223165 1.50087016389 1.29351914350 2.20190979625
edd@max:/tmp$

士气:打印精度几乎永远不会计算精度

关于c++ - Armadillo 复杂矩阵乘法早期近似,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29591265/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com