Boost logo

Boost :

From: Kresimir Fresl (fresl_at_[hidden])
Date: 2002-03-25 04:47:32


Joerg Walter wrote:

>>BTW, `std::valarray<>' hasn't `insert()', `erase()' and `clear()' member
>>functions, but if corresponding functions in `numerics::vector<>' are
>>not used, this shouldn't be a problem.

> Under certain circumstances, these members should be called. If a sparse
> matrix result is assigned to a dense matrix, the assignment operation should
> be dispatched to the sparse matrix logic: clear the dense matrix and insert
> the rhs elements at the corresponding positions.

Well, `clear()', `insert()' & `erase()' can be added to traits class.
`clear()' can be simply:

    template <typename T>
    struct array_traits<std::valarray<T> > {
       // ...
       static void clear (std::valarray<T>& va) { va = T(); }
    };

and `insert()' & `erase()' can be similar to corresponding
functions in `(un)bounded_array<>'.

> In the last days I had another idea. To get the CLAPACK tests working, we
> needed to adapt raw T* pointers. We therefore recently introduced a class
> array_adaptor. Now another way to solve valarray adaption could be something
> like:
>
> valarray<double> va (size);
> array_adaptor<double> aa (size, &va [0]);
> vector<double, array_adaptor<double> > v (size, aa);
>
> What do you think?

Useful and very flexible addition. Maybe a bit verbose ;O)

Sincerely,

fres


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk