Boost logo

Ublas :

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


Hi

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 =
_system.DConstraints(q);
(gdb)
618 ublas::vector<double> dGv = prod(dG,v);
(gdb)
2598 return size1_;
(gdb)
618 ublas::vector<double> dGv = prod(dG,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)
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
'boost::numeric::ublas::external_logic'
   what(): external logic

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

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