
"Andy Little" <andy@servocomm.freeserve.co.uk> writes:
"David Abrahams" <dave@boost-consulting.com> wrote in message news:87irk2a0rd.fsf@pereiro.peloton...
"Andy Little" <andy@servocomm.freeserve.co.uk> writes:
The code below uses boost::tuple, but presumably fusion could do this stuff better?
I should note that one of the main reasons fusion tuples (which are "vector-like") are better for random access than boost::tuple (which is "slist-like") is that, even taking into account the memoizing nature of template instantiation, the latter generates O(N^2) instantiations to access N elements of a tuple with at<>, whereas the former takes only O(N).
Unfortunately I couldnt check out the relative compile time performance, as I ran out of elements in Boost.Tuple when I tried making a 4 x 4 matrix, else I would have stuck with it for the moment. ( I opted just to use one tuple)
Especially where Boost.Tuple (a cons-list implementation) is concerned, I don't see why one tuple would be better than 5.
However maybe its a good move to try out Boost.Fusion. Although the docs said the move from tuple was as easy as changing from get to at, I found that there was a big change, because AFAICS Fusion uses references everywhere,
Surely not everywhere. fusion::tuple<int,long> contains an int and a long, not references to int and long.
and the compiler refused to assign anything, for reasons I am not clear on. Anyway after changing from result_of::at_c to result_of::value_at_c things seemed to go more smoothly. (That is using the Boost Review version of fusion). IOW I am succcessfully fused ! FWIW compiling a 2x2, 3x3, and 4x4 with some quan::quantities in, a multiply of each by itself and some output, takes about 22 seconds, on my AMD Atlhon 1.25Ghz system The trickiest part is working out an algorithm to do cofactors of the matrices (to get the inverse), but I may just hard code them, unless anyone has any suggestions ...?
Yeah, use the fusion algorithms to express what you'd ordinarily do with looping if these were homogeneous vectors/matrices. -- Dave Abrahams Boost Consulting www.boost-consulting.com