On Oct 22, 11:59 am, William Stein <wst...@gmail.com> wrote:

>
> Here's a benchmark (the first thing I tried):
>
> sage: a = random_matrix(RDF,2000)
> sage: timeit('a*a')
> 5 loops, best of 3: 1.8 s per loop
> sage: b = matlab('rand(2000)')
> sage: timeit('b*b')
> 5 loops, best of 3: 3.4 s per loop
>
> Sage is twice as fast.  

Hi,

how do you run matlab command from sage like this above? I have sage
4.1.2 and matlab 2008b installed on my windows XP PC, but when I run
the above, it tells me it can't start matlab:

a = random_matrix(RDF,2000)
timeit('a*a')
5 loops, best of 3: 2.17 s per loop

b = matlab('rand(2000)')
timeit('b*b')
....
TypeError: Unable to start matlab

I assume I need to do some 'configuration' documented somewhere which
I did not even try to look for. may be because iam student and using
student version of matlab?

But when I run the above inside my matlab itself, then this is what I
get:

If I understand what timeit() does above, I just had a quick look at
its documentaion, is that it ran b*b 5 times, took the mean, then
repeated this 3 times, then at the end it took the lowest (best) of
all the means found?

if so, then I get 1.03 seconds with matlab, which is twice as fast as
sage? if my above understanding of timeit() is wrong, I could redo
this: (there is no timeit() in matlab, so had to write few lines of
code to emulate it)

b=rand(2000);
timesall=zeros(3,1);
times=zeros(5,1);
for i=1:3
    for j=1:5
        tic; b*b; times(j)=toc;
    end
    timesall=mean(times);
end
min(timesall)

timesall =

    1.0300

Using Mathematica 7.0, I did the same, and I get 1.14 seconds

In[1]:= b = Table[RandomReal[UniformDistribution[{0, 1}]], {2000},
{2000}];
timesall = Table[0, {3}];
times = Table[0, {5}];

For[i = 1, i <= 3, i++,
  {
    For[j = 1, j <= 5, j++,
           times[[j]] = Timing[b . b][[1]]
         ];
    timesall[[i]] = Mean[times];
  }
]
Min[timesall]

Out[6]= 1.1438000000000001


ps. I am using the notebook interface with sage with sun virtual box.
may be this adds more delay? should I run the sage command from the
sage command line?

all on same PC, no other apps runnings at the same time. Intel 2 core
Due E6850@ 3 Ghz , 3 GB ram, windows XP sp2

--Nasser
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to