Charles R Harris wrote:
On 9/10/07, *Christopher Barker* <Chris.Barker@noaa.gov STL either, so I'm not sure there is any downside to valarray. It looks like neither one [vector or valarray] supports any kind of "view" semantics, so for the purposes of numpy array wrapping, they really aren't any different.
I think that the originator of valarray saying it was misguided might be considered a downside.
I had read that, though interestingly, I haven't seen any more recent commentary about the issues at all.
In any case, it appears that what Budge is saying is that the original goal of valarray being well used for optimized numerical routines isn't going to happen (I don't think it has, though there is a PPC altivec version out there). However std::vector doesn't have any numerical optimizations either, so I don't see any reason to choose std::vector over std:valarray.
My real question is what compiler and library writers are doing -- has anyone (OK, I guess MS and gcc are all I care about anyway) built anything optimized for them? Are they going to dump them? Who knows? What do you mean by optimization ? I think this question is the key. I remember having used blitz at some point, and I thought it was terrible. It is really complicated, and to get good performances was really difficult. Maybe I used it wrongly, I don't know (this was a few years ago). But at some point, I decided to just use plain C arrays instead:
Christopher Barker wrote: the code was much faster, and actually much easier (I really hate template syntax). I personnally don't think all the template things worth it for optimizing temporaries (which was the goal of blitz): the complexity cost is enormous, for not much benefit. I think C++ is much more useful for the automatic memory management through RAII, which is what std::vector gives you. As long as you think about setting the right size to avoid resizes, all other considerations are not worthwhile IMHO. C speed is already quite good on modern CPU, and std::vector gives you that. If your compiler supports restrict, use it (http://www.cellperformance.com/mike_acton/2006/05/demystifying_the_restrict_...), this will give you "Fortran speed". The fact that, while C++ being a popular language, a standard class for matrix algebra does not exist yet shows me that this is not that useful, or too complicate to develop. cheers, David