Boost logo

Ublas :

From: Preben Hagh Strunge Holm (preben_at_[hidden])
Date: 2007-03-07 15:21:43


When I compile with -O2 I have problems - with no optimization there's
no problem at all.

What I do is:

  namespace ublas = boost::numeric::ublas;


  void MechComputer::ConstraintCorrection(const ublas::vector<double>& m,
                                          ublas::vector<double>& q,
                                          ublas::vector<double>& v,
                                          double qerror,
                                          double verror,
                                          unsigned int limit) {
614 // Loop
615 unsigned int count = 0;
616 ublas::vector<double> G = _system.Constraints(q);
617 ublas::compressed_matrix<double> dG = _system.DConstraints(q);
618 ublas::vector<double> dGv = prod(dG,v);
619 std::cout << "...619..." << std::endl;

there is no problem until line 618 - it never get's to line 619..

Since this is a function the ublas::vector<double> dGv = prod(dG,v)
should be assigned on the stack at the moment of the creation of prod(dG,v).

However this seems to become a problem (sometimes).

Here is the debug-session from gdb:
618 ublas::vector<double> dGv = prod(dG,v);
(gdb) n
617 ublas::compressed_matrix<double> dG =
618 ublas::vector<double> dGv = prod(dG,v);
2598 return size1_;
618 ublas::vector<double> dGv = prod(dG,v);
65 if (size_) {
64 alloc_(a), size_ (size) {
65 if (size_) {
87 if (__builtin_expect(__n > this->max_size(), false))
90 return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp)));
66 data_ = alloc_.allocate (size_);
74 vector_assign<scalar_assign> (*this, ae);
Assertion failed in file
../../RobWork/ext/boost/numeric/ublas/detail/vector_assign.hpp at line 371:
detail::expression_type_check (v, cv)
Qt has caught an exception thrown from an event handler. Throwing
exceptions from an event handler is not supported in Qt. You must
reimplement QApplication::notify() and catch all exceptions there.

terminate called after throwing an instance of
   what(): external logic

Program received signal SIGABRT, Aborted.
0xffffe410 in __kernel_vsyscall ()

so what is wrong with this? Why does vector_assign fail here? And only
when optimization is done?

Can anyone explain this to me? Do I assign the ublas::vector incorrectly?

Thansk for helping

Best regards,
Preben Holm