[macstl-dev] Re: Question about sized booleans
lipovsky at skycomputers.com
Tue Jul 19 23:55:36 WST 2005
>> I want to be able to do:
>> v3 = (v1 || v2), where v1 & v2 are valarray<int> and use v3 any way I
>> want to. Currently, I have problems with that. Declaring v3 as
>> valarray<int> produces compile-time error (the same goes for
>> valarray<macstl::boolean<int> >, as mentioned before). Declaring v3
>> as valarray<bool> produces scalar code. The same goes for operator&&
>> . What to do... Any suggestions ;) ?
> Yes I will do that for 0.3.1.
>> 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 this:
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.
More information about the macstl-dev