I have several matrices (2D matrices) sizes can go up to 30000*30000 and I need to do matrix multiplications. However, even if I use 16 Digits the calculation take extremely long compare to MATLAB. I am not expecting Mathematica to be faster but not 100 times slower.
So for MATLAB I create
A=rand(300,300);
tic
A*A;
toc
and it takes only 0.004 seconds with format long ( double precision)
For Mathematica
a = RandomReal[{-10, 10}, {300, 300}, WorkingPrecision -> 15];
AbsoluteTiming[f = a.a;]
taking 13 seconds and there is no time difference if I increase the WorkingPrecision to 30. But more interestingly if I put the working precision to 6 digits (single precision) time consumed is same. An example.
a = RandomReal[{-10, 10}, {300, 300}, WorkingPrecision -> 6];
AbsoluteTiming[f = N[a].N[a];]
AbsoluteTiming[g = a.a;]
Max[Abs[f - g]]
The difference between g and f far being zero. I don't understand why I get different results in here.
I can't imagine doing such a calculation with really large matrices. I am certain that something is not right in my Mathematica approach. What is the way to speed up matrix multiplication in Mathematica.