Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Matlab (vs. C/FORTRAN) a respectable language for a professional mathematical researcher of the 21st century? [closed]

I am a die hard user of matlab, mostly because this is what I learned first and I have not encountered a problem with a significant enough difference to switch. I come from numerical optimization/linear algebra, where I have performed optimization and eigenvalue computations in millions of degrees of freedom. Recently, I have entered the realm of randomness, where I was originally under the impression I would be forced to change. But, after optimizing code, and carefully initializing the seed to the random number generator, I am able to do the same Monte Carlo tasks as my contemporaries in roughly the same time. My understanding has been that base-level 'if' statements, etc., are significantly slower in matlab. However, if there are significant computations within each loop which can be vectorized, I'm not convinced C would be better. And, anyway, matlab seems to do just fine, in the sense that my upper bound is no less than any other professional (and in many cases, seems to be more). I have a feeling that I will get lots of responses from pro-C people here, who have written off matlab long ago as some trivial toy language. I am a professional researcher and contend that matlab is competitive for the highest level computationally intensive mathematical programming. Am I wrong ? Do I need to consider changing to a lower-level language, such as C/FORTRAN ? Why or why not ? Are there others like me ? Thanks alot! Cheers

like image 928
mr matlab Avatar asked Dec 11 '10 13:12

mr matlab


People also ask

Is MATLAB better than Fortran?

The most significant difference is MATLAB expensive software, more easy to write the code but take longer time to run but FORTRAN is free software, more difficult to code but shorter time to run the code.

Should I learn MATLAB or Fortran?

If you intend to do heavy numerical or scientific computations, then Fortran is definitely worth learning. It is a high-level language comparable to Python/MATLAB, yet with speed that can be 500 times faster than MATLAB/Python.

Why do physicists still use Fortran?

Fortran has legacy code Physicists usually try to minimize the amount of coding they do, therefore, if legacy code exists they will use it. Even if old code is hard to read, poorly documented, and not the most efficient, it is often faster to use old validated code than to write new code.

Is MATLAB faster than Fortran?

MATLAB was built for matrix computations, and while yes it is slower than C++/Fortran compiled code, there is a powerful way to make it really fast called vectorization, which is easy to learn. These are a single line of code, that can manipulate data in many ways in giant arrays/matrices.


1 Answers

I work with a team of professional research geophysicists though I'm more of a numerical software engineer myself. I think that if your work is numerical mathematics then Matlab is very suitable, especially so since you are already skilled in its use.

You might write faster programs if you picked up C or Fortran, though perhaps not as much faster as you would hope since Matlab uses, for a lot of its numerical routines, the same BLAS (etc) libraries as you would if you were writing in C or Fortran. But from my working experience my colleagues find the ability to write programs more quickly much more important than writing quicker programs. They generate a lot of ideas which, upon reflection, they later reject. The added speed of development that Matlab gives over and above C and Fortran means that they go through the whole cycle (which generally includes visualisation of results) a lot more quickly and do it more often, so doing more science by some crude measure.

(As an aside: one of the jobs I get is to turn some of the Matlab code that is not rejected into Fortran programs for execution on the company's large clusters. But that's what happens to some of our codes when the initial research is complete and we want to deploy them for production.)

I'd also point out that Matlab has good parallel computing capabilities (if you can afford them) through its Parallel Compute Toolbox, which will probably be of interest as your problems become larger and you realise that you are underusing some of your cores, gosh it's even got integration with GPU computing in the latest release.

In a nutshell I'd suggest that staying with Matlab will allow you to focus on your mathematical research and not divert your attention to wrestling with a new toolset. Especially so since you do not suggest that Matlab is inadequate for your expected needs.

like image 72
High Performance Mark Avatar answered Oct 02 '22 13:10

High Performance Mark