octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #63444] "if (COND)" is much slower than "if (a


From: Rik
Subject: [Octave-bug-tracker] [bug #63444] "if (COND)" is much slower than "if (all (COND))"
Date: Tue, 29 Nov 2022 13:30:20 -0500 (EST)

Follow-up Comment #2, bug #63444 (project octave):

Oh boy, things are always so complicated.  

[comment #1 comment #1:]
> This comparison also points out that "if (all (NaN))" is not the same as "if
(NaN)".  Is that difference compatible with Matlab?

Checking with Matlab, "all (NaN)" returns true while "if (NaN)" produces an
error about converting NaN to logical value.  So, Octave is Matlab
compatible.

I also checked "if ([0, 1, NaN])" to see if Matlab would short-circuit out,
but it does not.  Hence, if we want to stay Matlab-compatible I don't think 
we can really make this more efficient.  Octave has to process all N items of
the array.  The advantage of not running, effectively, "! isnan (x) && all
(x)" is that the value you are checking would definitely be available on a CPU
register.  I doubt this is what is killing performance.


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?63444>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

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