Title
Incomplete Valarray Subset Definitions
Status
nad
Section
[numarray]
Submitter
Nico Josuttis

Created on 1998-09-29.00:00:00 last changed 171 months ago

Messages

Date: 2010-10-21.18:28:33

Rationale:

This is not a defect in the Standard; it is a request for an extension.

Date: 2010-10-21.18:28:33

Proposed resolution:

Extend all valarray subset types so that they offer all valarray operations.

Date: 1998-09-29.00:00:00

You can easily create subsets, but you can't easily combine them with other subsets. Unfortunately, you almost always needs an explicit type conversion to valarray. This is because the standard does not specify that valarray subsets provide the same operations as valarrays.

For example, to multiply two subsets and assign the result to a third subset, you can't write the following:

va[slice(0,4,3)] = va[slice(1,4,3)] * va[slice(2,4,3)];

Instead, you have to code as follows:

va[slice(0,4,3)] = static_cast<valarray<double> >(va[slice(1,4,3)]) * 
                   static_cast<valarray<double> >(va[slice(2,4,3)]);

This is tedious and error-prone. Even worse, it costs performance because each cast creates a temporary objects, which could be avoided without the cast.

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg221
2010-10-21 18:28:33adminsetmessages: + msg220
1998-09-29 00:00:00admincreate