Search NASAโŒ• Search

NASA NTRS ยท 20010081822

The Design of a Templated C++ Small Vector Class for Numerical Computing

Abstract

We describe the design and implementation of a templated C++ class for vectors. The vector class is templated both for vector length and vector component type; the vector length is fixed at template instantiation time. The vector implementation is such that for a vector of N components of type T, the total number of bytes required by the vector is equal to N * size of (T), where size of is the built-in C operator. The property of having a size no bigger than that required by the components themselves is key in many numerical computing applications, where one may allocate very large arrays of small, fixed-length vectors. In addition to the design trade-offs motivating our fixed-length vector design choice, we review some of the C++ template features essential to an efficient, succinct implementation. In particular, we highlight some of the standard C++ features, such as partial template specialization, that are not supported by all compilers currently. This report provides an inventory listing the relevant support currently provided by some key compilers, as well as test code one can use to verify compiler capabilities.

Keep this discovery

Explore connections, maps & timelines

BibTeXRIS

Moran, Patrick J.. 2000-06-20. The Design of a Templated C++ Small Vector Class for Numerical Computing. https://ntrs.nasa.gov/citations/20010081822

Cite the original work for its findings. Save a collection to share your selection of sources.