Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > valarray/slice_array

Reply
Thread Tools

valarray/slice_array

 
 
Chris Forone
Guest
Posts: n/a
 
      06-13-2008
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
 
Reply With Quote
 
 
 
 
Chris Forone
Guest
Posts: n/a
 
      06-16-2008
Alf P. Steinbach schrieb:
> * Chris Forone:
>>
>> is there a technical reason why slice_array do not have an
>> index-operator?

>
> 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!
>
>
>> is it complicated to extend slice_array with such an index-operator?

>
> 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
 
Reply With Quote
 
 
 
 
MiB
Guest
Posts: n/a
 
      06-16-2008
On 16 Jun., 07:03, "Alf P. Steinbach" <(E-Mail Removed)> wrote:
> * 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments