 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Peter C. Chapin Guest
|
Posted: Sun Jun 26, 2005 2:10 pm Post subject: valarray? |
|
|
The other day I was reading about std::valarray while waiting for a
doctor's appointment (it beats the magazines they usually have in the
waiting room). I've never needed to use valarray but I figured I might as
well learn about it. The ideas used seem pretty neat. I can see how the
various slicing features might be of interest to numerical folks. I can
also see how the interface would be awkward at best.
I realize that valarray is not generally liked. I'm curious now about its
future status. Are there going to be changes to valarray in the next C++
standard to address its issues?
Peter
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Holger Sebert Guest
|
Posted: Mon Jun 27, 2005 1:18 am Post subject: Re: valarray? |
|
|
Peter C. Chapin wrote:
| Quote: | The other day I was reading about std::valarray while waiting for a
doctor's appointment (it beats the magazines they usually have in the
waiting room). I've never needed to use valarray but I figured I might as
well learn about it. The ideas used seem pretty neat. I can see how the
various slicing features might be of interest to numerical folks. I can
also see how the interface would be awkward at best.
I realize that valarray is not generally liked. I'm curious now about its
future status. Are there going to be changes to valarray in the next C++
standard to address its issues?
|
(Sorry, Peter, I think, I accidentally sent you this to your email address)
Hi,
my experience is that people doing numerics with C++ use libraries like
Blitz or they own specialized hand-coded classes.
In "The C++ Programming Language" it is said, that std::valarray is
meant as a means for easy building of matrix classes (using "slices" and
"generalized slices"). However, for sophisticated numerics this isn't
enough since their are so many special cases which need special types of
matrices (sparse, triangular, ...) and the corresponding vectors.
Normally, libraries that provide matrix classes also provide compatible
vector classes, which makes std::valarray superfluous.
So, I think std::valarray is useful for elementary numerics which do not
need other specialized data structures.
I, personally, like std::valarray because it is said (!) that
compilers can "aggressively optimize" the code using std::valarray (e.g.
doing some SIMD stuff, etc.)
But I wonder if an implementation of the STL exists which exhaust these
possibilities of optimization. Does anyone know of any?
Regards,
Holger
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
glenlow@pixelglow.com Guest
|
Posted: Tue Jun 28, 2005 9:59 am Post subject: Re: valarray? |
|
|
I have written a version of valarray that uses Altivec on PowerPC and
MMX/SSE/SSE2/SSE3 on Intel for optimizing. It comes in 9x-22x the speed
of the std::valarray on most platforms. Moreover because of the
expression template technique, I can reorganize certain valarray
expressions to use optimum sets of these SIMD opcodes e.g.
v1 * v2 + v3; // these are all valarrays
is automatically treated like fma (v1, v2, v3) which is faster on
Altivec.
Even the std::slice'ing uses Altivec, although I have not gotten a
decent speedup on slicing.
http://www.pixelglow.com/macstl/
Cheers,
Glen Low, Pixelglow Software
www.pixelglow.com
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
benben Guest
|
Posted: Wed Jun 29, 2005 8:30 am Post subject: Re: valarray? |
|
|
WOW!! Good job Glen!!
I think we are all looking foreward to more platform-dependent,
compiler-specific, very very very very dirty optimizations on valarray!!
ben
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|