Skip to content
Browse files

Fix for RANSAC n_unique_integers bug

  • Loading branch information...
1 parent 9013441 commit ec91b6fe41393edb44048ed38874d6b700d53c75 @ScottMcMichael ScottMcMichael committed
Showing with 18 additions and 17 deletions.
  1. +2 −1 src/vw/Math/RANSAC.h
  2. +16 −16 src/vw/Math/Vector.h
View
3 src/vw/Math/RANSAC.h
@@ -128,10 +128,11 @@ namespace math {
int n = samples.size();
VW_ASSERT(size >= n, ArgumentErr() << "Not enough samples (" << n << " / " << size << ")\n");
+ const double divisor = static_cast<double>(RAND_MAX) + 1.0;
for (int i = 0; i < n; ++i) {
bool done = false;
while (!done) {
- samples[i] = int( (double(std::rand()) / double(RAND_MAX)) * size );
+ samples[i] = static_cast<int>( (static_cast<double>(std::rand()) / divisor) * size );
done = true;
for (int j = 0; j < i; j++)
if (samples[i] == samples[j])
View
32 src/vw/Math/Vector.h
@@ -1263,24 +1263,24 @@ namespace math {
}
__VW_UNARY_VECTOR_FUNCTOR(operator-,ArgNegationFunctor)
- __VW_UNARY_VECTOR_FUNCTOR(cos,ArgCosFunctor)
- __VW_UNARY_VECTOR_FUNCTOR(acos,ArgAcosFunctor)
- __VW_UNARY_VECTOR_FUNCTOR(sin,ArgSinFunctor)
- __VW_UNARY_VECTOR_FUNCTOR(asin,ArgAsinFunctor)
- __VW_UNARY_VECTOR_FUNCTOR(tan,ArgTanFunctor)
- __VW_UNARY_VECTOR_FUNCTOR(atan,ArgAtanFunctor)
- __VW_UNARY_VECTOR_FUNCTOR(sqrt,ArgSqrtFunctor)
- __VW_UNARY_VECTOR_FUNCTOR(exp,ArgExpFunctor)
- __VW_UNARY_VECTOR_FUNCTOR(cosh,ArgCoshFunctor)
- __VW_UNARY_VECTOR_FUNCTOR(sinh,ArgSinhFunctor)
- __VW_UNARY_VECTOR_FUNCTOR(tanh,ArgTanhFunctor)
- __VW_UNARY_VECTOR_FUNCTOR(log,ArgLogFunctor)
+ __VW_UNARY_VECTOR_FUNCTOR(cos, ArgCosFunctor)
+ __VW_UNARY_VECTOR_FUNCTOR(acos, ArgAcosFunctor)
+ __VW_UNARY_VECTOR_FUNCTOR(sin, ArgSinFunctor)
+ __VW_UNARY_VECTOR_FUNCTOR(asin, ArgAsinFunctor)
+ __VW_UNARY_VECTOR_FUNCTOR(tan, ArgTanFunctor)
+ __VW_UNARY_VECTOR_FUNCTOR(atan, ArgAtanFunctor)
+ __VW_UNARY_VECTOR_FUNCTOR(sqrt, ArgSqrtFunctor)
+ __VW_UNARY_VECTOR_FUNCTOR(exp, ArgExpFunctor)
+ __VW_UNARY_VECTOR_FUNCTOR(cosh, ArgCoshFunctor)
+ __VW_UNARY_VECTOR_FUNCTOR(sinh, ArgSinhFunctor)
+ __VW_UNARY_VECTOR_FUNCTOR(tanh, ArgTanhFunctor)
+ __VW_UNARY_VECTOR_FUNCTOR(log, ArgLogFunctor)
__VW_UNARY_VECTOR_FUNCTOR(log10,ArgLog10Functor)
- __VW_UNARY_VECTOR_FUNCTOR(real,ArgRealFunctor)
- __VW_UNARY_VECTOR_FUNCTOR(imag,ArgImagFunctor)
+ __VW_UNARY_VECTOR_FUNCTOR(real, ArgRealFunctor)
+ __VW_UNARY_VECTOR_FUNCTOR(imag, ArgImagFunctor)
__VW_UNARY_VECTOR_FUNCTOR(floor,ArgFloorFunctor)
- __VW_UNARY_VECTOR_FUNCTOR(ceil,ArgCeilFunctor)
- __VW_UNARY_VECTOR_FUNCTOR(abs,ArgAbsFunctor)
+ __VW_UNARY_VECTOR_FUNCTOR(ceil, ArgCeilFunctor)
+ __VW_UNARY_VECTOR_FUNCTOR(abs, ArgAbsFunctor)
#ifndef WIN32
__VW_UNARY_VECTOR_FUNCTOR(round,ArgRoundFunctor)
#endif

0 comments on commit ec91b6f

Please sign in to comment.
Something went wrong with that request. Please try again.