[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## binary logical ops optimized

**From**: |
Jaroslav Hajek |

**Subject**: |
binary logical ops optimized |

**Date**: |
Sat, 14 Mar 2009 23:35:59 +0100 |

hello,
for anyone interested:
I've implemented compound logical operators in the current tip:
http://hg.savannah.gnu.org/hgweb/octave/rev/dc6bda6f9994
That means, Octave will now be able to compute the expressions a & !b,
a | !b, !a & b, !a | b without forming the negation as a temporary.
I have also optimized the bool ops slightly.
a short benchmark follows:
n = 1e7;
a = rand (n, 1) > 0.5;
b = rand (n, 1) < 0.5;
tic; a & b; toc
tic; a | b; toc
tic; a & !b; toc
tic; !a & b; toc
tic; a | !b; toc
tic; !a | b; toc
with a recent tip:
Elapsed time is 0.119011 seconds.
Elapsed time is 0.116198 seconds.
Elapsed time is 0.177725 seconds.
Elapsed time is 0.173214 seconds.
Elapsed time is 0.168783 seconds.
Elapsed time is 0.168297 seconds.
with new tip:
Elapsed time is 0.0503938 seconds.
Elapsed time is 0.050772 seconds.
Elapsed time is 0.0508418 seconds.
Elapsed time is 0.0503359 seconds.
Elapsed time is 0.045867 seconds.
Elapsed time is 0.045948 seconds.
this may be superseded by lazy evaluation in future, but that is a
very long term project, and I'm not even sure how it should work.
This means that the fastest way to write certain logical expressions may change.
regards
--
RNDr. Jaroslav Hajek
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz

[Prev in Thread] |
**Current Thread** |
[Next in Thread] |

**binary logical ops optimized**,
*Jaroslav Hajek* **<=**