On Fri, Oct 31, 2008 at 12:35 AM, David Bateman <[EMAIL PROTECTED]> wrote:
> Dave Goel wrote:
>>
>>
>>> Yeah, I can't come up with anything of the top of my head. But I'll make
>>> you a deal. If you write an m-file version using for-loops, that handle
>>> the N-dimensional case, then I'll re-implement it in C++.
>>
>> I am including here an m-version, tested, and also attaching it.  But,
>> really, I stand by my last post.  Why re-implement the wheel?  We
>> should simply use the exact same logic and facilities used by
>> tmpcumsum.
>
> The MX_CUMULATIVE_OP and MX_ND_CUMULATIVE_OP macros from
> liboctave/mx-inlines.cc both use a line something like
>
>  prev_val = prev_val OP elem (iter_idx);
>
> where as for cummax you'd need that to read
>
>  prev_val = FN (prev_val, elem (iter_idx));
>
> where FN is the max function for cummax or the min function for cummin.
> So yes although the modification to Octave itself is small to allow the
> use of these existing macros to do the job, there is still a change
> needed or a new macro created.
>

One day, I intend to replace these macros by templates, able to use
any binary functor, and possibly using std::accumulate.

I think that we should replace executive code in macros by templates
wherever possible. Using macros might have been sensible in 1997, but
I think that C++ compilers today are mature enough with templates &
inlining so that we can safely use them without losing performance.
The "heavy" templating used in oct-inttypes.h is an example.

Just out of curiosity, what use is "cumulative p-norm" for?

cheers

-- 
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Octave-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/octave-dev

Reply via email to