Boost logo

Ublas :

From: Nico Galoppo (nico_at_[hidden])
Date: 2006-10-12 18:59:32


Hi, I'd like to write a ublas function that takes a vector_expression as input,
as follows:

   template <typename graph_type, typename V, typename skeleton_type>
   void set_rhs(skeleton_type & skeleton, graph_type & g, const
ublas::vector_expression<V> & b)
   {
     for (skeleton_type::bone_iterator bone = skeleton.bones_begin();
       bone != skeleton.bones_end(); ++bone)
     {
       const unsigned c = bone->get_bone_number() * 6;

       // !! needs negative sign here!
       //ublas::vector_expression<V> minus_b = - b;

       bone->get_core().save_solution(ublas::subrange( - b(), c, c+6));
     }
   }

I have some efficiency concerns on that last line. If all the data in b() is
going to be multiplied by -1.0 and stored in a temporary variable at each
iteration in the for loop, then this is going to be ugly.

I tried the uncommenting the line second-to-last line and replacing -b() by
minus_b, but the compiler didn't like that:

d:\dev\hybrid\hybrid\articulated\character_baraff.h(179) : error C2440:
'initializing' : cannot convert from 'boost::numeric::ublas::vector_unary<E,F>'
to 'boost::numeric::ublas::vector_expression<E>'

Any help would be appreciated, thanks!

--nico

-- 
nico galoppo von borries     |  address: 119 fidelity st., carrboro
comp. graphics phd. student  |           north carolina, 27510 USA
UNC, chapel hill             |  phone: +1 (919) 962-1898 (office)
                              |         +1 (919) 942-4388 (home)
                              |  email: nico at cs dot unc dot edu
                              |  homepage: http://www.ngaloppo.org