Boost logo

Ublas :

From: Preben Hagh Strunge Holm (preben_at_[hidden])
Date: 2007-03-08 16:36:41


>> and try to split the creation and the assignement
>>
>> vector dg( prod_size );
>> noalias(dg) = prod(...);
>
> Hmm... I already tried that... but it didn't work either..
>
> The strange thing is that I can do this without trouble:
> std::cout << prod(dG,v) << std::endl;
>
> and it actually works without trouble.

Hmm... this is really strange - I haven't even shifted the compiler, but
now it doesn't work again... (obviously I managed to "fix" the error but
only for a short moment).

I really don't know what to do now.

source:
---------
void MechComputer::ConstraintCorrection(double qerror, double verror,
unsigned int limit) {
     static const ublas::vector<double>& m = _system.GetMass();
     // Loop
     unsigned int count = 0;
     ublas::vector<double> G = _system.Constraints(this->_q);
     ublas::compressed_matrix<double> dG = system.DConstraints(this->_q);
     std::cout << prod(dG,this->_v) << std::endl;

     std::cout << "dGv.size() : " << prod(dG,this->_v).size() << std::endl;
     std::cout << "v.size() : " << _v.size() << std::endl;
     std::cout << "dG.size() : (" << dG.size1() << ", " << dG.size2()
<< ")" << std::endl;

     ublas::vector<double> dGv(dG.size1());
     noalias(dGv) = prod(dG, this->_v);
     std::cout << "noalias done" << std::endl;

     ublas::vector<double> dGv2 = prod(dG,this->_v);
     std::cout << "prod(dG,v) calculated - creation/assignment " <<
std::endl;
---------

and output:
---------
[66](-1.03923e-16,7.41255e-18,5.96049e-18,-1.34787e-18,6.15827e-19,4.29118e-16,-5.04778e-17,6.81962e-17,4.06814e-16,-7.12409e-17,-1.13986e-17,1.64599e-11,1.65064e-11,4.55925e-17,2.18045e-16,4.83928e-17,8.22994e-10,3.95692e-16,3.15028e-16,5.40351e-16,1.16241e-12,8.22994e-10,6.59681e-11,8.22994e-11,6.58395e-11,8.22994e-11,6.5793e-11,8.22996e-10,7.74306e-17,-6.93968e-17,3.10826e-15,3.21354e-12,8.22994e-10,9.66782e-11,9.63666e-11,2.01454e-16,1.63315e-11,1.64602e-11,4.8339e-09,3.41044e-16,-6.92599e-16,3.28507e-15,-7.78745e-12,4.8339e-09,3.89387e-10,4.83394e-10,3.86712e-10,4.8339e-10,3.87023e-10,4.83412e-09,2.62788e-15,-3.64614e-16,2.28797e-13,6.67664e-11,4.8339e-09,3.89356e-09,3.91051e-09,1.84907e-14,9.40256e-11,9.67007e-11,1.94677e-07,-9.49182e-14,-3.23241e-16,2.29538e-13,4.23706e-10,1.94677e-07)
dGv.size() : 66
v.size() : 72
dG.size() : (66, 72)
noalias done
prod(dG,v) calculated - creation/assignment
---------

for some reason I get passed this first part now... but the next time I
calculate dGv and assign it to the same variable I get the exact same
trouble:

source:
-----
             double qerr = norm_2(G);
             double verr = norm_2(dGv);

             while((qerr > qerror || verr > verror) && count <= limit) {
               ++count;
               ublas::matrix<double, ublas::column_major> mM = M(dG, m);
               CorrectCoordinates(mM, G, dG, dGv, m, this->_q, this->_v);

               G = _system.Constraints(this->_q);
               dG = _system.DConstraints(this->_q);
(614) dGv = prod(dG, this->_v);
               qerr = norm_2(G);
               verr = norm_2(dGv);
             }
-----

and error output:
------
614 dGv = prod(dG, this->_v);
(gdb)
65 if (size_) {
(gdb)
64 alloc_(a), size_ (size) {
(gdb)
65 if (size_) {
(gdb)
87 if (__builtin_expect(__n > this->max_size(), false))
(gdb)
90 return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp)));
(gdb)
66 data_ = alloc_.allocate (size_);
(gdb)
74 vector_assign<scalar_assign> (*this, ae);
(gdb)
Assertion failed in file
../../RobWork/ext/boost/numeric/ublas/detail/vector_assign.hpp at line 371:
detail::expression_type_check (v, cv)
terminate called after throwing an instance of
'boost::numeric::ublas::external_logic'
   what(): external logic
------

so this seems to me to be really strange now - especially because the
error seems to vary very much depending on the source-structure.

Regards,
Preben