Topic: valarray slice_array et. al.


Author: Gabriel Dos Reis <dosreis@cmla.ens-cachan.fr>
Date: Fri, 15 Feb 2002 16:47:59 GMT
Raw View
"Roland" <roland.schwarz@chello.at> writes:

[...]

| Is there an alternative implementation available (i.e. compiler independent
| reference library?)

There is STLPort -- but I don't know whether it has a valarray
implementation.

--
Gabriel Dos Reis, dosreis@cmla.ens-cachan.fr

---
[ 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    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: "Roland" <roland.schwarz@chello.at>
Date: Wed, 13 Feb 2002 15:59:49 GMT
Raw View
"Gabriel Dos Reis" <dosreis@cmla.ens-cachan.fr> wrote in message
news:fl8z9y6tlw.fsf@jambon.cmla.ens-cachan.fr...
> "Roland" <roland.schwarz@chello.at> writes:
>
> | Having
> |
> | valarray<double> va(10), vb(19);
> |
> | I cannot do
> |
> | va[slice(3,1,3)] = vb[slice(0,1,3)];
> |
> | or
> |
> | va[slice(3,1,3)] += vb[slice(0,1,3)];
> |
> | I'd expect, that the respective elements of va would be changed.
> | Is the implementation of my library bad or do I miss something?
>
> The above is well-formed.
>
> Which implementation are you using?
>

I am using Visual C++ 6.0.
Is there an alternative implementation available (i.e. compiler independent
reference library?)

Roland



---
[ 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    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: "Roland" <roland.schwarz@chello.at>
Date: Sun, 10 Feb 2002 04:34:19 GMT
Raw View
Having

valarray<double> va(10), vb(19);

I cannot do

va[slice(3,1,3)] = vb[slice(0,1,3)];

or

va[slice(3,1,3)] += vb[slice(0,1,3)];

I'd expect, that the respective elements of va would be changed.
Is the implementation of my library bad or do I miss something?
Is this the way the standard intends the use of valarray?

( The first case simply does nothing - no assignment or error.
While in the second case my compiler tells me: could not deduce template
argument.)

Thank you,
Roland



---
[ 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    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: sakrejda@pacbell.net (Grzegorz Sakrejda)
Date: Sun, 10 Feb 2002 23:16:16 CST
Raw View
"Roland" <roland.schwarz@chello.at> wrote in
<hl598.503072$5G5.3640316@news.chello.at>:

>Having
>
>valarray<double> va(10), vb(19);
>
>I cannot do
>
>va[slice(3,1,3)] = vb[slice(0,1,3)];
>
>or
>
>va[slice(3,1,3)] += vb[slice(0,1,3)];
>

 valarray operator [slice] returns slice_array.
 slice_array has assignment operators with valarray arguments.

  you have to write :

   va[slice(3,1,3)] += valarray<double>(vb[slice(0,1,3)]);

 This creates temporary valarray<double> with one element,
 Why operator = doesn't cause compiler error ??.


  grzegorz


---
[ 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    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: gsakrejda@hotmail.com (Grzegorz Sakrejda)
Date: Mon, 11 Feb 2002 19:20:39 GMT
Raw View
"Roland" <roland.schwarz@chello.at> wrote in
<hl598.503072$5G5.3640316@news.chello.at>:

>Having
>
>valarray<double> va(10), vb(19);
>
>I cannot do
>
>va[slice(3,1,3)] = vb[slice(0,1,3)];
>
>or
>
>va[slice(3,1,3)] += vb[slice(0,1,3)];
>


  va[slice(3,1,3)] += valarray<double> ( vb[slice(0,1,3)]);


  slice_array assignment operators take only valarray arguments.

  Why do you need this assignment ??



  grzegorz

---
[ 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    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: "Roland" <roland.schwarz@chello.at>
Date: Wed, 13 Feb 2002 01:26:02 GMT
Raw View
"Grzegorz Sakrejda" <gsakrejda@hotmail.com> wrote in message news:8qy98.312>

>   slice_array assignment operators take only valarray arguments.
>
>   Why do you need this assignment ??
>

Assume a matrix stored in valarray<double> matrix1(1000*100).
Now having some other matrix valarrray<double> matrix2(30*1000).

Assign the n'th row of second to first matrix.
This will create an principal superfluous temporary copy, when I first
use the copy contructor to create an intermediary.

Or do you ask what application I need this construct for?
I am trying to write a simple matrix class. And altough I currently
do have only about 10000 times 6 for dimensions I care about
performance. I am afraid that the temporary copy will unnecessary
degrade it.

Also the inability of doing this assignment was very unecpected to me
so I am also asking if there any reasons for it.

Thank you,
Roland



>
>
>   grzegorz
>
> ---
> [ 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    ]
> [              --- Please see the FAQ before posting. ---               ]
> [ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]
>


---
[ 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    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: Gabriel Dos Reis <dosreis@cmla.ens-cachan.fr>
Date: Wed, 13 Feb 2002 01:55:54 GMT
Raw View
"Roland" <roland.schwarz@chello.at> writes:

[...]

| Also the inability of doing this assignment was very unecpected to me
| so I am also asking if there any reasons for it.

The assignment should work.

As to the performance degradation, I already raised the issue and
made a detailled proposal to extend valarray capabilities to helper
classes.  That they were missing from the standard is a defect,
IMNSHO.

--
Gabriel Dos Reis, dosreis@cmla.ens-cachan.fr

---
[ 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    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: Gabriel Dos Reis <dosreis@cmla.ens-cachan.fr>
Date: Wed, 13 Feb 2002 02:01:27 GMT
Raw View
"Roland" <roland.schwarz@chello.at> writes:

| Having
|
| valarray<double> va(10), vb(19);
|
| I cannot do
|
| va[slice(3,1,3)] = vb[slice(0,1,3)];
|
| or
|
| va[slice(3,1,3)] += vb[slice(0,1,3)];
|
| I'd expect, that the respective elements of va would be changed.
| Is the implementation of my library bad or do I miss something?

The above is well-formed.

Which implementation are you using?

--
Gabriel Dos Reis, dosreis@cmla.ens-cachan.fr

---
[ 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    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]