valarray/slice_array

C

Chris Forone

hello group,

is there a technical reason why slice_array do not have an
index-operator? is it complicated to extend slice_array with such an
index-operator?

cheers, chris
 
C

Chris Forone

Alf said:
* Chris Forone:

First, disclaimer: I'm not familiar with valarray.

But much of the reason that I'm not familiar with it is that valarray is
essentially an unfinished class.

One that isn't used in practice, the Most Useless part of the standard
library.

Who knows what the author had in mind?

That said, it looks like much of the purpose was to provide a class
where operations could be optimized by certain processors, performing
element operations in parallel, and that /could/ be easier for the
processor to do if direct modifictions of single elements was
prohibited. However, valarray itself allows modification of single
elements. So, it seems like something half-baked, with the design not
fully flushed out, but beware of the disclaimer above!



Yes, don't do it.

To avoid gross inefficiency you'd have to delve into your particular
implementation, i.e. non-portable code.

Otherwise you could always copy that subset to a new valarray, change a
single element, and copy the whole shebang back... :)


Cheers, & hth.,

- Alf

thanks, chris
 
M

MiB

* Chris Forone:
But much of the reason that I'm not familiar with it is that valarray is
essentially an unfinished class.

One that isn't used in practice, the Most Useless part of the standard library.

Who knows what the author had in mind?

Valarrays have been designed with linear algebra and numeric
computation in mind.
The internal memory layout is a one dimensional array (quick
operations on all elements and on two equally sized valarrays).
The slice_arrays allow elegant access e.g. to row/column vectors in
matrices, or for example the diagonal vector.

Tensor math also comes to mind as an area where valarrays can be
efficient as containers.

If you have to deal with big matrices, you learn to like the class.
Its not a very frequent task for most developers, though.

best,

Michael.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

slice_array problem in vs2005 0
enum class 1
valarray performance 11
a valarray error with mingw 1
valarray Initialization Question 3
valarray iterators? 2
valarray 1
Trying to fix this python script 5

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top