|
Boost Users : |
From: Andy Little (andy_at_[hidden])
Date: 2006-09-08 16:39:21
"Andy Little" <andy_at_[hidden]> wrote
<...>
> Anyway I have continued hacking away and so here is my latest efforts, using
> fusion to do a dot product of two vectors.
> Maybe it would be a useful example in the fusion docs?. Anyway here it is
> FWIW:
A couple of bugs found in my code, as detailed below . --->
Also I found I had to comment out the specialisation of as_vector<0>
in < boost/fusion/sequence/conversion/detail/as_vector.hpp>
in the Boost Review version to get it to compile OK in GCC4.0.1
I havent tried the CVS version of the file but it looks unchanged relative to my
version.
regards
Andy Little
<...>
> // more arg reversing
> template <typename F>
> struct reverse_f_args{
>
> template <typename Rhs, typename Lhs>
> struct result{
> typedef typename F:: template result<
> Rhs,Lhs
> >::type type;
> };
> template <typename Rhs, typename Lhs>
> typename result<Rhs,Lhs>::type
> operator()( Rhs const & rhs, Lhs const & lhs )const
> {
> F f;
-----------------------
- f(lhs,rhs);
+ return f(lhs,rhs);
----------------------
<...>
> // do the dot_product
-----------------------------
-
- result_type result = boost::fusion::fold(
-
+
+ result_type result = 0;
+
+ boost::fusion::fold(
-------------------------------------------------
> boost::fusion::transform(seq1,seq2,quan::operator_times()),
> boost::ref(result),
> quan::fusion::reverse_assign_f_args<quan::operator_plus_equals>()
> );
> assert(quan::compare(result,30,1e-12) ==0);
> std::cout << result <<'\n';
>
> }
> -----------------------------
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net