Any Octave users? What is this code snippet actually doing?
Bruce Dawson
jbd at codemeta.com
Sun Apr 7 10:46:10 EDT 2013
Write a review of the book and indicate that the code therein has bugs!
You're the eyeball + 1. Strengthen your power by reporting the bug in a
public forum! Help prevent others from falling into the same hole.
--Bruce
On 04/07/2013 10:35 AM, Bruce Labitt wrote:
> On 04/06/2013 04:58 PM, Michael ODonnell wrote:
>>> kmax=1;
>>> kfactor=(kmax-1.0)/delta/(orderbc+1.0)/delbc^orderbc;
>>> Unless matlab treats floats and ints differently than most other
>>> languages, I'd say its a bug because zero over anything is always zero.
>> Shame on anybody who'd intentionally code something like
>> that without also providing a comment about such a seemingly
>> counterintuitive approach. >-/ Let's hope it's simply a bug...
>>
>> Out of morbid curiosity, how does Octave report the value of
>> kfactor after
>>
>> kmax=1
>> kfactor=(kmax-1.0)
>>
>> ??
>>
>> _______________________________________________
>> gnhlug-discuss mailing list
>> gnhlug-discuss at mail.gnhlug.org
>> http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/
>>
>>
> kfactor = 0 is reported by octave in debug mode.
>
> That's a long bit of code
>
> kfactor=(kmax-1.0)/delta/(orderbc+1.0)/delbc^orderbc;
>
> just to set it to zero. Clearly a bug, or just plain wrong and not
> thought through. Drives me nuts, since this construct was used for the
> x, y, and z axes.
>
> Guess I'll have to contact one of the authors of the book. The graduate
> student that wrote the code has since graduated. (Got her PhD int
> 2010.) Humph, you'd think the code samples for something this
> complicated would be better.
>
> \rant on
> The level of commenting in the code sample is not up to teaching
> standards, IMHO. If you are doing something tricky, write a descriptive
> comment on it! (I can't even remember tricky stuff I did last week
> without good comments.) Please, everyone, don't write ultra dense code
> like this, spaces are your friend!
>
> dx(:,2:je_tot,2:ke_tot)=C1ex(:,2:je_tot,2:ke_tot).*
> dx(:,2:je_tot,2:ke_tot)+
> C2ex(:,2:je_tot,2:ke_tot).*((hz(:,2:je_tot,2:ke_tot)-hz(:,1:je_tot-1,2:ke_tot))-
> (hy(:,2:je_tot,2:ke_tot)-hy(:,2:je_tot,1:ke_tot-1)))./delta;
>
> Especially if there are 5 more lines just like it, with slightly
> differing indices, with no spaces in between!
> \rant off
>
> As you were. :)
>
>
>
> _______________________________________________
> gnhlug-discuss mailing list
> gnhlug-discuss at mail.gnhlug.org
> http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/
More information about the gnhlug-discuss
mailing list