Topic: [Announce] approx. std. numerical array (valarray)


Author: vandevod@cs.rpi.edu (David Vandevoorde)
Date: 23 Feb 95 15:29:43 GMT
Raw View
I would like to announce an approximate implementation of the proposed
(at least, I believe it's still in the ANSI/ISO working paper) standard
C++ numerical array. The original proposal is (I believe) mainly the
work of Kent Budge and includes specification for a type template
"valarray<T>".

I call my implementation "valarray<Troy>", BTW, and it is available via
anonymous ftp on "ftp.cs.rpi.edu" (128.213.4.50) in the directories
staring at pub/vandevod/Valarray.

My implementation is "approximate" in the following senses:
 . my valarray<T> class does not have the "shift" and "apply"
   member functions mentioned in the defining document
   (might be easily fixed, but haven't thought about it yet).
 . valarray<Troy> does not include some of the more complex
   subsetting facilities; simple "slices" are supported, but
   generalized slices, boolean masks and indirection are not
   there yet. I expect to add indirection first.
 . In general, I do not maintain the interface as proposed
   in the document by Kent Budge. This has to do with the main
   implementation decisions. I did however spend quite some
   efforts to keep things (as far as possible/reasonable)
   compatible at source code level.

I believe this implementation is interesting because the applicable
operators and functions (to valarray<T>) have been written to avoid
the creation of large temporaries. Thus, code like:

 valarray<double> a(no_init,100), b(no_init, 100), c(no_init, 100);
 // ... fill in some values
 a = a+b+c;

will not produce a single extraneous valarray<double> object (I hope :).
Moreover, the above assignment will be performed in a single loop
without "run-time expression analysis". I must admit I have not yet
analyzed how well this codes performs (I guess that's one of the
reasons I put it for grabbing already :). For good performance, it
definitely requires an optimizer with good inlining and invariant code
movement capabilities.

This implementation relies (very) heavily on automatic template
instantiation. I tried a simple program on 5 compiler/platform
pairs and managed to get it working on 4 of these. Unfortunately,
the fifth one is the GNU C++ compiler (version 2.6.3 on Sun).

Documentation is in preparation; right now I can only refer you to
the source in the distributions. Questions can also be addressed
at:
 vandevod@cs.rpi.edu

 Daveed