From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-08-21 06:20:32
From: "John Max Skaller" <skaller_at_[hidden]>
> Peter Dimov wrote:
> > the unnecessary initialization in this case is rarely a measurable
> Matrix r; // initialised ..
> r = x * y;
This is a general problem, it's not specific to std::vector.
Matrix r(x * y);
> is an O(n) + O(n^3) operation. The O(n) is irrelevant for large n.
> But not in the common case n=2, where it represents 20% of overall time.
> For addition, its 50%.
Big-O tells you nothing for small n. And sometimes for relatively large n.
memset() is incredibly fast nowadays. :-)
-- Peter Dimov Multi Media Ltd.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk