In MMA I have a 2d matrix whose each entry is a irrational number(in fraction format in MMA). Say:
{{-4, -(2/Sqrt[5]), 0]},
{-(4/Sqrt[20]), -4, -Sqrt[2]},
{1, 0, 0}}
Now I would like to convert it into decimals and save as much precision as possible before feeding it into C++.
I learnt that 16 significant decimal places is the limit of double precision in C++. So I would like to convert the matrix above into one with scientific notation with entries like:
1.1234567890123456E10
or
1.1234567890123456E-10
Then I can make the best use of 16 digits in the double precision and give the matrix directly to C++.
Here comes the question:
- how could I convert the fractions into the "E" notation?
and
- save the matrix in a plain text file friendly to the Eigen Library I'm using? See the format here: Example
matrix << 1,0,1,0, 1,0,1,0, 1,0,1,0,
I have tried ScientificForm but what was exported was like:
ScientificForm[-0.816496580927726]...
What if I just need the numbers in E notation?
CForm[$MachineEpsilon]
? $\endgroup$