38 #if !EIGEN_VERSION_AT_LEAST(3, 3, 0)
44 template <
typename Derived>
47 using S =
typename Derived::Scalar;
50 const Eigen::MatrixBase<Derived>& min,
51 const Eigen::MatrixBase<Derived>& max)
59 return Random::uniform<S>(
mMin(i, j),
mMax(i, j));
62 const Eigen::MatrixBase<Derived>&
mMin;
63 const Eigen::MatrixBase<Derived>&
mMax;
66 template <
typename Derived>
69 using S =
typename Derived::Scalar;
72 const Eigen::MatrixBase<Derived>& min,
73 const Eigen::MatrixBase<Derived>& max)
81 return Random::uniform<S>(
mMin[i],
mMax[i]);
84 const Eigen::MatrixBase<Derived>&
mMin;
85 const Eigen::MatrixBase<Derived>&
mMax;
96 struct functor_has_linear_access<
97 dart::math::detail::UniformScalarFromMatrixFunctor<T>>
105 template <
typename T>
106 struct functor_has_linear_access<
107 dart::math::detail::UniformScalarFromVectorFunctor<T>>
126 template <
template <
typename...>
class C,
typename... Ts>
129 template <
template <
typename...>
class C>
132 template <
template <
typename...>
class C,
typename T>
134 = decltype(is_base_of_template_impl<C>(std::declval<T*>()));
136 template <
typename T>
143 template <
typename T,
typename Enable =
void>
151 template <
typename T>
153 T, typename
std::enable_if<
154 std::is_same<typename std::remove_cv<T>::type, short>::value
155 || std::is_same<typename std::remove_cv<T>::type, int>::value
156 || std::is_same<typename std::remove_cv<T>::type, long>::value
157 || std::is_same<typename std::remove_cv<T>::type, long long>::value
158 || std::is_same<typename std::remove_cv<T>::type, unsigned short>::value
159 || std::is_same<typename std::remove_cv<T>::type, unsigned int>::value
160 || std::is_same<typename std::remove_cv<T>::type, unsigned long>::value
161 || std::is_same<typename std::remove_cv<T>::type, unsigned long long>::value
171 template <
typename S,
typename Enable =
void>
179 template <
typename S>
182 typename
std::enable_if<std::is_floating_point<S>::value>
::type>
184 static S
run(S min, S max)
195 template <
typename S>
198 typename
std::enable_if<
199 is_compatible_to_uniform_int_distribution<S>::value>
::type>
201 static S
run(S min, S max)
211 template <
typename Derived,
typename Enable =
void>
219 template <
typename Derived>
222 typename
std::enable_if<
223 !Derived::IsVectorAtCompileTime
224 && Derived::SizeAtCompileTime == Eigen::Dynamic>
::type>
226 static typename Derived::PlainObject
run(
227 const Eigen::MatrixBase<Derived>& min,
228 const Eigen::MatrixBase<Derived>& max)
230 #if EIGEN_VERSION_AT_LEAST(3, 3, 0)
231 const auto uniformFunc = [&](
int i,
int j) {
232 return Random::uniform<typename Derived::Scalar>(min(i, j), max(i, j));
234 return Derived::PlainObject::NullaryExpr(
235 min.rows(), min.cols(), uniformFunc);
237 return Derived::PlainObject::NullaryExpr(
247 template <
typename Derived>
250 typename
std::enable_if<
251 Derived::IsVectorAtCompileTime
252 && Derived::SizeAtCompileTime == Eigen::Dynamic>
::type>
254 static typename Derived::PlainObject
run(
255 const Eigen::MatrixBase<Derived>& min,
256 const Eigen::MatrixBase<Derived>& max)
258 #if EIGEN_VERSION_AT_LEAST(3, 3, 0)
259 const auto uniformFunc = [&](
int i) {
260 return Random::uniform<typename Derived::Scalar>(min[i], max[i]);
262 return Derived::PlainObject::NullaryExpr(min.size(), uniformFunc);
264 return Derived::PlainObject::NullaryExpr(
272 template <
typename Derived>
275 typename
std::enable_if<
276 !Derived::IsVectorAtCompileTime
277 && Derived::SizeAtCompileTime != Eigen::Dynamic>
::type>
279 static typename Derived::PlainObject
run(
280 const Eigen::MatrixBase<Derived>& min,
281 const Eigen::MatrixBase<Derived>& max)
283 #if EIGEN_VERSION_AT_LEAST(3, 3, 0)
284 const auto uniformFunc = [&](
int i,
int j) {
285 return Random::uniform<typename Derived::Scalar>(min(i, j), max(i, j));
287 return Derived::PlainObject::NullaryExpr(uniformFunc);
289 return Derived::PlainObject::NullaryExpr(
297 template <
typename Derived>
300 typename
std::enable_if<
301 Derived::IsVectorAtCompileTime
302 && Derived::SizeAtCompileTime != Eigen::Dynamic>
::type>
304 static typename Derived::PlainObject
run(
305 const Eigen::MatrixBase<Derived>& min,
306 const Eigen::MatrixBase<Derived>& max)
308 #if EIGEN_VERSION_AT_LEAST(3, 3, 0)
309 const auto uniformFunc = [&](
int i) {
310 return Random::uniform<typename Derived::Scalar>(min[i], max[i]);
312 return Derived::PlainObject::NullaryExpr(uniformFunc);
314 return Derived::PlainObject::NullaryExpr(
321 template <
typename T,
typename Enable =
void>
328 template <
typename T>
331 typename
std::enable_if<std::is_arithmetic<T>::value>
::type>
333 static T
run(T min, T max)
340 template <
typename T>
343 typename
std::enable_if<is_base_of_matrix<T>::value>
::type>
345 static T
run(
const Eigen::MatrixBase<T>& min,
const Eigen::MatrixBase<T>& max)
352 template <
typename S,
typename Enable =
void>
360 template <
typename S>
363 typename
std::enable_if<std::is_floating_point<S>::value>
::type>
365 static S
run(S mean, S sigma)
374 template <
typename S>
377 typename
std::enable_if<
378 is_compatible_to_uniform_int_distribution<S>::value>
::type>
380 static S
run(S mean, S sigma)
382 using DefaultFloatType = float;
384 static_cast<DefaultFloatType
>(mean),
385 static_cast<DefaultFloatType
>(sigma));
386 return static_cast<S
>(
std::round(realNormal));
391 template <
typename T,
typename Enable =
void>
398 template <
typename T>
401 typename
std::enable_if<std::is_arithmetic<T>::value>
::type>
403 static T
run(T min, T max)
412 template <
typename S>
419 template <
typename FixedSizeT>
421 typename FixedSizeT::Scalar min,
typename FixedSizeT::Scalar max)
423 return uniform<FixedSizeT>(
424 FixedSizeT::Constant(min), FixedSizeT::Constant(max));
428 template <
typename DynamicSizeVectorT>
431 typename DynamicSizeVectorT::Scalar min,
432 typename DynamicSizeVectorT::Scalar max)
434 return uniform<DynamicSizeVectorT>(
435 DynamicSizeVectorT::Constant(size, min),
436 DynamicSizeVectorT::Constant(size, max));
440 template <
typename DynamicSizeMatrixT>
444 typename DynamicSizeMatrixT::Scalar min,
445 typename DynamicSizeMatrixT::Scalar max)
447 return uniform<DynamicSizeMatrixT>(
448 DynamicSizeMatrixT::Constant(rows, cols, min),
449 DynamicSizeMatrixT::Constant(rows, cols, max));
453 template <
typename S>
std::string type
Definition: SdfParser.cpp:82
std::uniform_int_distribution< IntType > UniformIntDist
Definition: Random.hpp:52
std::normal_distribution< FloatType > NormalRealDist
Definition: Random.hpp:55
std::uniform_real_distribution< FloatType > UniformRealDist
Definition: Random.hpp:49
static S normal(S mean, S sigma)
Returns a random number from a normal distribution.
Definition: Random-impl.hpp:454
static GeneratorType & getGenerator()
Returns a mutable reference to the random generator.
Definition: Random.cpp:39
static S uniform(S min, S max)
Returns a random number from an uniform distribution.
Definition: Random-impl.hpp:413
Definition: Random-impl.hpp:92
decltype(is_base_of_template_impl< C >(std::declval< T * >())) is_base_of_template
Definition: Random-impl.hpp:134
std::true_type is_base_of_template_impl(const C< Ts... > *)
is_base_of_template< Eigen::MatrixBase, T > is_base_of_matrix
Definition: Random-impl.hpp:137
double round(double _x)
Definition: Helpers.hpp:144
Definition: BulletCollisionDetector.cpp:65
Definition: SharedLibraryManager.hpp:46
static T run(T min, T max)
Definition: Random-impl.hpp:403
Definition: Random-impl.hpp:393
static S run(S mean, S sigma)
Definition: Random-impl.hpp:380
static S run(S mean, S sigma)
Definition: Random-impl.hpp:365
Definition: Random-impl.hpp:354