New user self-registration is currently disabled. Please email eigen-core-team @ lists.tuxfamily.org if you need an account.
Bug 1075 - AlignedBox::sample() method when using AlignedBoxXd fails assertion
AlignedBox::sample() method when using AlignedBoxXd fails assertion
Status: RESOLVED FIXED
Product: Eigen
Classification: Unclassified
Component: Geometry
3.2
x86 - 64-bit Mac OS
: Normal Crash
Assigned To: Nobody
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2015-09-28 20:30 UTC by niekbouman
Modified: 2015-09-30 09:45 UTC (History)
4 users (show)



Attachments

Description niekbouman 2015-09-28 20:30:06 UTC
I am using an AlignedBoxXd, when I call sample() on it, I get an assertion failure:

Assertion failed: (index >= 0 && index < size()), function operator[], file /opt/local/include/eigen3/Eigen/src/Core/DenseCoeffsBase.h, line 378. 


The problems seems to be that the vector 'r' in the code below (AlignedBox.h, line 166), which is of type VectorType (I guess VectorXd in this case) is not given a size before it is used in 'r[d]' (line 171).

  inline VectorType sample() const
  165   {
  166     VectorType r;
  167     for(Index d=0; d<dim(); ++d)
  168     {
  169       if(!ScalarTraits::IsInteger)
  170       {
  171         r[d] = m_min[d] + (m_max[d]-m_min[d])
  172              * internal::random<Scalar>(Scalar(0), Scalar(1));
  173       }
  174       else
  175         r[d] = internal::random(m_min[d], m_max[d]);
  176     }
  177     return r;
  178   }
Comment 1 Gael Guennebaud 2015-09-30 09:45:31 UTC
Thank you for the report.

default: https://bitbucket.org/eigen/eigen/commits/114569164dbc/
3.2: https://bitbucket.org/eigen/eigen/commits/9dac2e213021/

Note You need to log in before you can comment on or make changes to this bug.