Topic: valarray<kc> class
Author: Kevin Copps <kc@isc.tamu.edu>
Date: 1996/05/01 Raw View
For those interested in discussion of the ANSI/ISO
C++ standard
valarray class for numeric arrays, and those
interested simply
in a good numeric vector class,
I have made a partial implementation of valarray
available.
(to see the proposed standard documention point
your browser to
http://dogbert.lbl.gov/FAQ/C++_WP_HTML/lib-numeric
s.html)
The present implementation relies heavily on the
STL function
classes, and in fact, an extension of the STL
function classes are
suggested by it. The source compiles with no
warnings on the
highest warning level of Microsoft Visuall C++ 4.1
Find source code and examples for valarray<kc> at
http://yoyodyne.tamu.edu/oop/oopcpp.html
My implementation of valarray is significant
because of the following advantages:
1. small additional member functions make it
closely parallel
the STL container classes, making it possible to
use the STL
algorithms with valarray.
2. all mathematical scalar and vector operations
are implemented using "expression templates". That
is, every application of an operator on valarray
will result in an inline template expansion. This
avoids the creation of temporaries and has been
shown to result
in speeds close to hand tuned C code.
3. The additional function classes added to the
STL form a
complete set of operations suitable for creating a
function pointer algebra class, or a general
expression class, useful for passing
expressions into functions.
The disadvantages I perceive are the following:
1. A tradeoff of speed with large code size; all
the inline
template expansions can create larger code sizes
than the more
conventional array classes now available in
commercial libraries.
2. Even small and medium sized expressions, when
instantiated, can create very long class names.
These long names put a strain on
compilers and may confuse debuggers.
--
Kevin Copps
Interdisciplinary Engineering
Texas A&M University
kc@isc.tamu.edu
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: Nathan Myers <ncm@cantrip.org>
Date: 1996/05/01 Raw View
Kevin Copps wrote:
>
> For those interested in discussion of the ANSI/ISO
> C++ standard valarray class for numeric arrays...
> I have made a partial implementation of valarray
> available.
> Find source code and examples for valarray<kc> at
>
> http://yoyodyne.tamu.edu/oop/oopcpp.html
Actually, he means:
http://yoyodyne.tamu.edu/oop/oopsoft.html
I would like to see a short summary comparing this work
against David Vandevoorde's version.
Nathan Myers
ncm@cantrip.org
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: vandevod@cs.rpi.edu (David Vandevoorde)
Date: 1996/05/02 Raw View
>>>>> "NM" == Nathan Myers <ncm@cantrip.org> writes:
[ ... about valarray implementations ]
NM> I would like to see a short summary comparing this work against
NM> David Vandevoorde's version.
I only browsed Kevin's code briefly, so what I say may not be
accurate and/or complete.
1) ``Expression Templates'': Kevin's implementation corresponds to
Todd Veldhuizen's. The difference with mine is that a virtual
table is emitted for every valarray operator/function instance,
whereas valarray<Troy> only emits one per non-trivial assignment/
construction operation. This will become a non-issue once we've
got more widely available member function templates.
2) The design of the return-types of valarray<kc> is similar to that
of valarray<Troy> 1.x; in particular, there is no name commonality.
Valarray<Troy> 2.y brings back valarray return-types at the
expense of a second template parameter (this is the subject of the
--- IMO --- most important open valarray issue).
3) Valarray<kc> has an STL-like container interface comparable to
that of the standard vector<T> template. It also relies on STL
in its implementation.
4) I believe that valarray<kc> adds two levels of template nesting
per operator/function (and I vaguely remember this is also the
case in the vector code that came with Todd Veldhuizen's reports).
5) Valarray<kc> does not (yet) include any subsetting (valarray<Troy>
2.0 also only implements a subset of the subset operations :^).
6) Valarray<kc> has the pre-Santa Cruz assignment semantics.
7) Valarray<Troy> 2.0 is deviant in some of its interfaces (e.g., min
and max functions), whereas valarray<kc> conforms to the DWP in
this respect.
Daveed
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]