For Programmers: Free Programming Magazines  


Home > Archive > Matlab > October 2006 > C++ in Matlab: preserving time machine resource









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author C++ in Matlab: preserving time machine resource
Nicola

2006-10-31, 4:07 am

Dear All,
given that MatLab is really more time-expensive than C++, if I write
a code in C++, will it be as slow as an .m code in MatLab?

Why do I not run in directly in C++? Because I need to take advantage
of the Distributed Computing Engine toolbox: is there a similar
clustering resource in C++? I've never used it.

Thank You, any further advice will be really appreciated.

Nick
Steve Amphlett

2006-10-31, 4:07 am

Nicola wrote:
>
>
> Dear All,
> given that MatLab is really more time-expensive than C++, if I
> write
> a code in C++, will it be as slow as an .m code in MatLab?


Depends how good your C++ code is. Bear in mind that ML relies on
some pretty quick underlying Fortran for much of its matrix
manipulation, which you're unlikely to beat with DIY C++ code.

> Why do I not run in directly in C++? Because I need to take
> advantage
> of the Distributed Computing Engine toolbox: is there a similar
> clustering resource in C++? I've never used it.


Natively no, not in the language itself. However, try googling for
MPI and OpenMP.
Mousa

2006-10-31, 8:02 am

Hi Nicola,

Given that you want to use the Distributed Engine toolbox in matlab
but at the same time you want to benefit from the speed of c++
processing, you can call c++ code within matlab.

In other words you can write the main code in matlab and then call a
c++ fragment for part of the code. on how to this you need to look into
the Mex function.

I hope this is helpful. If you don't know about the Mex function, I
can send you a code sample if you wish.

Cheers,
Mousa

Nicola wrote:
> Dear All,
> given that MatLab is really more time-expensive than C++, if I write
> a code in C++, will it be as slow as an .m code in MatLab?
>
> Why do I not run in directly in C++? Because I need to take advantage
> of the Distributed Computing Engine toolbox: is there a similar
> clustering resource in C++? I've never used it.
>
> Thank You, any further advice will be really appreciated.
>
> Nick


Rune Allnor

2006-10-31, 8:02 am


Steve Amphlett skrev:
> Nicola wrote:
>
> Depends how good your C++ code is. Bear in mind that ML relies on
> some pretty quick underlying Fortran for much of its matrix
> manipulation, which you're unlikely to beat with DIY C++ code.


True. But with everything else, even poor C++ code is likely to be at
least
an order of magnitude faster than matlab.

Rune

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com