This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Valarrays and [altivec] vectors (was Re: [PATCH]: Handle vector modes in genopinit.c, c-typeck.c)



Apologies in jumping so late in this discussion (Phil, thanks for
having CC:ed me).

Phil Edwards <pedwards@disaster.jaj.com> writes:

| On Thu, Nov 29, 2001 at 07:20:27PM +0000, Joseph S. Myers wrote:
| > On Thu, 29 Nov 2001, Per Bothner wrote:
| > 
| > > Given my proposal that vectors should be compatible with
| > > the standard C++ valarray type template, I would rather
| > > that this be "the same operations that are allowed on valarrays
| > > would be allowed on vectors".

Agreed.  I welcome any efforts to provide some hardware support for
valarrays. 

| > Can you add (or apply other binary operations) to valarrays of different
| > types?  If so, what is the return type?
| 
| No, valarrays are templated on a value type.  Value types may not be mixed.
| To add a valarray of int and a valarray of char, you'd have to convert
| the v<char> to v<int> and then add the two v<int>'s.

Exact.

| > What is the return type of adding
| > two valarrays of char?
| 
| A third valarray of char.

Exact.

| > When can valarrays be used in ? : conditional expressions?
| 
| I don't know of any restrictions here.  Gaby?

There is no implicit conversion valarray<T> -> bool.  So they can't be
used in the condition part of "?:", but they are certainly valid
arguments for the second and third operands are any C++ objects. 

| > Can operations be applied between valarrays of different lengths?
| 
| Undefined behavior.  I think the current implementation formats the user's
| hard drive.

Exact :-)

| > Can
| > they be applied between valarrays and scalars?
| 
| Yes.

Exact.

| > Can valarrays be used in a boolean context?
| 
| You mean something like "if (a_valarray)"?  I don't think there's a
| conversion operator required...

Yes, you're absolutely right.

However two valarray<T>s can be be used in equality or relational
comparaisons, the operation is componentwise and the result is a
valarray<bool>. One can also apply directly boolean operators to
valarray<bool>s, 

Thanks,

-- Gaby
CodeSourcery, LLC                       http://www.codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]