Subject: Re: [ublas] Why is there no constructor taking an initial value?
Date: 2009-01-24 13:46:55
sorry for sneaking in the conversation but...
am I wrong or such a constructor could be optimize heavily ... and result
faster than construct and do a subsequent fill?
> Thorsten Ottosen wrote:
>> Gunter Winkler skrev:
>>> Am Donnerstag, 22. Januar 2009 16:13 schrieb Thorsten Ottosen:
>>>> I was a bit surprised that there is no way to fill a
>>>> triangular_matrix with a default value. Say, I would have expected
>>>> this to work:
>>>> triangular_matrix<double> m(42,42,42);
>>>> Is there any reason why this constructor is not provided?
>>> because it is not needed:
>>> // untested
>>> triangular_matrix<double,lower> m((
>> Right. I do something similar to get a zero matrix. But that syntax is
>> *so* verbose. Normal STL containers has this type of constructor, and
>> so users expect it to be provided.
> I think a special constructor is not needed. It is not because STL
> containers have such constructors that other packages should follow the
> same ideas. I would suggest a function fill(a, value) which is much
> clearer than a constructor with three arguments. Such function could be
> used to fill any ublas mutable object. STL's solution
> std::fill(a.begin(), a.end(), value ) is not elegant either.
> ublas mailing list