mirror of
https://gitlab.com/libeigen/eigen.git
synced 2024-12-21 07:19:46 +08:00
Don't add EIGEN_DEVICE_FUNC to random() since ::rand is not available in Cuda.
This commit is contained in:
parent
a3ec89b5bd
commit
9254974115
@ -700,18 +700,16 @@ struct random_retval
|
||||
typedef Scalar type;
|
||||
};
|
||||
|
||||
template<typename Scalar> EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(random, Scalar) random(const Scalar& x, const Scalar& y);
|
||||
template<typename Scalar> EIGEN_DEVICE_FUNC inline EIGEN_MATHFUNC_RETVAL(random, Scalar) random();
|
||||
template<typename Scalar> inline EIGEN_MATHFUNC_RETVAL(random, Scalar) random(const Scalar& x, const Scalar& y);
|
||||
template<typename Scalar> inline EIGEN_MATHFUNC_RETVAL(random, Scalar) random();
|
||||
|
||||
template<typename Scalar>
|
||||
struct random_default_impl<Scalar, false, false>
|
||||
{
|
||||
EIGEN_DEVICE_FUNC
|
||||
static inline Scalar run(const Scalar& x, const Scalar& y)
|
||||
{
|
||||
return x + (y-x) * Scalar(std::rand()) / Scalar(RAND_MAX);
|
||||
}
|
||||
EIGEN_DEVICE_FUNC
|
||||
static inline Scalar run()
|
||||
{
|
||||
return run(Scalar(NumTraits<Scalar>::IsSigned ? -1 : 0), Scalar(1));
|
||||
@ -768,7 +766,6 @@ struct meta_floor_log2<n, lower, upper, meta_floor_log2_bogus>
|
||||
template<typename Scalar>
|
||||
struct random_default_impl<Scalar, false, true>
|
||||
{
|
||||
EIGEN_DEVICE_FUNC
|
||||
static inline Scalar run(const Scalar& x, const Scalar& y)
|
||||
{
|
||||
if (y <= x)
|
||||
@ -796,7 +793,6 @@ struct random_default_impl<Scalar, false, true>
|
||||
return Scalar(ScalarX(x) + offset);
|
||||
}
|
||||
|
||||
EIGEN_DEVICE_FUNC
|
||||
static inline Scalar run()
|
||||
{
|
||||
#ifdef EIGEN_MAKING_DOCS
|
||||
@ -815,13 +811,11 @@ struct random_default_impl<Scalar, false, true>
|
||||
template<typename Scalar>
|
||||
struct random_default_impl<Scalar, true, false>
|
||||
{
|
||||
EIGEN_DEVICE_FUNC
|
||||
static inline Scalar run(const Scalar& x, const Scalar& y)
|
||||
{
|
||||
return Scalar(random(x.real(), y.real()),
|
||||
random(x.imag(), y.imag()));
|
||||
}
|
||||
EIGEN_DEVICE_FUNC
|
||||
static inline Scalar run()
|
||||
{
|
||||
typedef typename NumTraits<Scalar>::Real RealScalar;
|
||||
@ -830,14 +824,12 @@ struct random_default_impl<Scalar, true, false>
|
||||
};
|
||||
|
||||
template<typename Scalar>
|
||||
EIGEN_DEVICE_FUNC
|
||||
inline EIGEN_MATHFUNC_RETVAL(random, Scalar) random(const Scalar& x, const Scalar& y)
|
||||
{
|
||||
return EIGEN_MATHFUNC_IMPL(random, Scalar)::run(x, y);
|
||||
}
|
||||
|
||||
template<typename Scalar>
|
||||
EIGEN_DEVICE_FUNC
|
||||
inline EIGEN_MATHFUNC_RETVAL(random, Scalar) random()
|
||||
{
|
||||
return EIGEN_MATHFUNC_IMPL(random, Scalar)::run();
|
||||
@ -1814,7 +1806,6 @@ inline bool isApproxOrLessThan(const Scalar& x, const Scalar& y,
|
||||
|
||||
template<> struct random_impl<bool>
|
||||
{
|
||||
EIGEN_DEVICE_FUNC
|
||||
static inline bool run()
|
||||
{
|
||||
return random<int>(0,1)==0 ? false : true;
|
||||
|
Loading…
Reference in New Issue
Block a user