[macstl-dev] Re: Question about sized booleans

Ilya Lipovsky lipovsky at skycomputers.com
Tue Jul 19 11:49:56 WST 2005

  • Previous message: [macstl-dev] Re: Question about sized booleans
  • Next message: [macstl-dev] Re: Question about sized booleans
  • Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]


On Tue, 19 Jul 2005, Glen Low wrote:
>> 
>> Can I have this: "valarray <macstl::boolean <float> > and then assign to it 
>> (vec1 < vec2), where vec1&vec2 are both of type "valarray <float>"? I tried 
>> it and failed. Should valarray be extended for sized booleans?
>
> All valarray expressions that return a bool already chunk as the appropriate 
> sized boolean e.g.
>
> valarray <float> a, b;
> a < b chunks as boolean <int>
> valarray <short> c, d;
> c < d chunks as boolean <short>
>
> You just can't store them in a valarray <bool> yet, because bool is usually a 
> fixed size on particular compilers/operating systems. You used to be able to 
> assign a 4 byte element to valarray <bool> in 0.1.x, but I had some problems 
> when I changed the architecture on 0.2.x so I had it #if 0'd out.
>
> I'll consider your request as it makes sense. However do note that boolean 
> <float> is only defined in SSE, to express the "subtle" difference between 
> boolean <float> and boolean <int> -- they use different SSE logical 
> operators, even though conceptually and register-wise they are identical. 
> Someone on the simdtech list, I think it was Holger, theorized they might use 
> different register files. We'd have to do a bit of inner type declaring to 
> get it come out correctly e.g.
>
> valarray <float>::boolean result = vec1 < vec2;
>
> and declare the boolean type inside of valarray <float>. A little 
> uncomfortable with this since this breaks compatibility with std::valarray -- 
> any suggestions?
>

Hmmm... I sound redundant, but the solution: to extend valarray 
operate on boolean <T> seems to be pretty elegant.

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 ;) ?

Also, how to properly use your select function?

-Ilya



  • Previous message: [macstl-dev] Re: Question about sized booleans
  • Next message: [macstl-dev] Re: Question about sized booleans
  • Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

More information about the macstl-dev mailing list