[macstl-dev] Re: Question about sized booleans
lipovsky at skycomputers.com
Wed Jul 20 02:01:30 WST 2005
>>> Also, how to properly use your select function?
>> The signature looks similar to this:
>> valarray <T> select (const valarray <bool>& boolexpr, const valarray
>> <T>& trueexpr, const valarray <T>& falseexpr);
>> And it will chunk i.e. optimize using Altivec whenever the boolexpr
>> has the same element size (and in SSE, similar base element) as the
>> trueexpr and falseexpr e.g.
>> valarray <float> a, b;
>> valarray <float> c = select (a < b, a, b); // is a naive
>> implementation of min (a, b)
>> You can replace any of the parameters with scalar "constants" (except
>> for all of the constants), so
>> c = select (true, a, b);
>> c = select (a < b, 1.0f, b);
>> c = select (a < b, a, 1.0f);
>> c = select (true, 1.0f, b);
>> c = select (true, a, 1.0f);
>> c = select (a < b, 1.0f, 2.0f);
>> will all work and the constants act as if they are a valarray
>> containing just that constant. (I say "constant" because you can
>> substitute a scalar variable instead but I wanted the examples to be
> So that means that I was using your "select(...)" correctly. Now I
> will be investigating other venues of resolution. My compiler gives me
> error: cannot convert `stdext::valarray<float>' to `fd_set*' for
> argument `2' to `int select(int, fd_set*, fd_set*, fd_set*, timeval*)'
> even though I don't include any system headers.
Due to shortage of time (can't waste more than 2 hours on the silly
issue) I propose a workaround: how about if we rename "select" into
"sel?" Seems work fine for me. Even though "select" sounds more
understandable, "sel" is shorter to type. Btw, we never invoke
"exponent" -- only "exp." So it doesn't go against any conventions.
What's your take on the proposition?
More information about the macstl-dev