help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re:


From: Shai Ayal
Subject: Re:
Date: Mon, 27 Mar 2006 18:53:05 +0200
User-agent: Thunderbird 1.5 (Windows/20051201)

Francesco Potorti` wrote:
I think this is a real-world problem. It is probably the biggest flaw in the matlab language, making you write programs which use unintuitive and hard to understand tricks just to avoid for-loops. As a real world example, have a look at the code for hist.m in octave. Instead of a ~N for-loop, it uses NlogN sorting just because sort is done in C and thus is faster.

I don't really think that this is a flaw.  The Octave (Matlab) language
is a matrix language, which is duly optimised for doing matrix
computations.  This is exactly what one would expect from a matrix
language.  Being fast at doing non-matrix operations is certainly an
added benefit, not the foremost objective of the language.

Do you agree?

I agree. I use octave because of these benifits.

I think that for-loops are an essential part of any programming language, and avoiding them has unfortunately become the hallmark of good matlab programming. When conducting job interviews for positions for which matlab/octave is relevant, one of my questions is:

how would you calculate a 10 sample running average on a 100 element vector?

I wouldn't say that using a for loop for such a small vector is wrong,
unless the operation is to be done many times.


true, but I think someone who has some experience with matlab/octave will understand at once that this question is all about avoiding the for-loop

Shai



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]