Reputation: 13
How can I increase the precision of armadillo complex matrix multiplication result. It approximates at 4 decimal place [ this is an example of the result (35.9682,-150.246) ] but i wanted a precision of atleast 8 decimal places. Thanks
Upvotes: 1
Views: 472
Reputation: 368301
As you don't seem to believe what I said in the comments:
#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;
}
which does as expected:
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$
Morale: printed precision is almost never computed precision.
Upvotes: 2