Boost logo

Ublas :

Subject: Re: [ublas] How to instantiate ublas vector from std::vector
From: Jeremy Conlin (jeremit0_at_[hidden])
Date: 2009-04-11 16:15:14


On Fri, Apr 10, 2009 at 9:15 AM, James C. Sutherland <
James.Sutherland_at_[hidden]> wrote:

> I would like to avoid copying the data. That could probably be done, but
>> would not be a great solution.
>>
>>
> Have a look at array adaptors. For example,
>
> typedef boost::numeric::ublas::shallow_array_adaptor<double>
> ArrayAdaptor;
> typedef boost::numeric::ublas::vector<double,ArrayAdaptor> VecType;
>
> vector<double> fieldValues;
> // ... initialize fieldValues ...
>
> VecType vec( npts, ArrayAdaptor(npts,fieldValues) );
> vector<double>::iterator ival = fieldValues.begin();
> for( VecType::iterator i=vec.begin(); i!=vec.end(); ++i, ++ival ){
> *i = *ival;
> }
>

Thanks for the suggestion, but how is this any different than copying the
data?
 Jeremy

> James
>
> _______________________________________________
> ublas mailing list
> ublas_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/ublas
>