Topic: Why no valarray<int>?


Author: hollyma@cray.com (Michael Holly)
Date: 1995/05/31
Raw View
In article 7pH@info.physics.utoronto.ca, peter@chinook.physics.utoronto.ca (Peter Berdeklis) writes:
>
> Being in a scientific computing environment, I think that
> the valarray<> classes are great.  Unless I am completely
> off the mark, it seems that they have been defined to
> address the optimization advantages that Fortran has over
> C/C++, mainly because of anti-aliasing.
>
> However, I wonder why the standard only requires vendors
> provide def'ns of valarray<float> and valarray<double>.
> It seems that valarray<int> and valarray<long> could
> benifit similarly.  I know that int and long are not often
> used in scientific computing, but they're sure used a lot
> in image processing, a field in which optimizations would
> probably be welcome. :-)
>
> Can any body shed any light on this?
>
>
> Pete
>
>
>
You are correct in surmising that the valarray class is intended to provide a non-aliased array, a la Fortran.  We certainly hope that this leads to
efficient scientific computing using C++.
The current standard definition of valarray is a template class; as far as I
know, users are free to instantiate it for any type, including int, for which
certain basic rules apply: for example, the type must support operator * if you
are going to instantiate a valarray operator *.
You could even instantiate a valarray for your own user-defined classes if
you wish.

---
********************************************************************************
*                                                                              *
*   -- Mike Holly (hollyma@cray.com)                                           *
*      (612)683-5897                                                           *
*      Cray Research, Inc.                                                     *
*      655F Lone Oak Drive                                                     *
*      Eagan, Mn. 55112                                                        *
*                                                                              *
********************************************************************************

--
********************************************************************************
*                                                                              *
*   -- Mike Holly (hollyma@cray.com)                                           *
*      (612)683-5897                                                           *





Author: peter@chinook.physics.utoronto.ca (Peter Berdeklis)
Date: 1995/05/31
Raw View
Being in a scientific computing environment, I think that
the valarray<> classes are great.  Unless I am completely
off the mark, it seems that they have been defined to
address the optimization advantages that Fortran has over
C/C++, mainly because of anti-aliasing.

However, I wonder why the standard only requires vendors
provide def'ns of valarray<float> and valarray<double>.
It seems that valarray<int> and valarray<long> could
benifit similarly.  I know that int and long are not often
used in scientific computing, but they're sure used a lot
in image processing, a field in which optimizations would
probably be welcome. :-)

Can any body shed any light on this?


Pete