17 template <
typename SrcScalar,
typename TgtScalar,
typename EnableIf =
void>
19 static SrcScalar
value() {
return internal::random<SrcScalar>(); }
23 template <
typename SrcScalar,
typename TgtScalar>
26 typename
internal::
enable_if<NumTraits<SrcScalar>::IsInteger && NumTraits<TgtScalar>::IsInteger &&
27 !NumTraits<TgtScalar>::IsSigned &&
28 (std::numeric_limits<SrcScalar>::digits < std::numeric_limits<TgtScalar>::digits ||
29 (std::numeric_limits<SrcScalar>::digits == std::numeric_limits<TgtScalar>::digits &&
30 NumTraits<SrcScalar>::IsSigned))>::type> {
32 SrcScalar
a = internal::random<SrcScalar>();
33 return a < SrcScalar(0) ? -(a + 1) : a;
38 template <
typename SrcScalar,
typename TgtScalar>
42 NumTraits<SrcScalar>::IsInteger && NumTraits<TgtScalar>::IsInteger && !NumTraits<SrcScalar>::IsSigned &&
43 (std::numeric_limits<SrcScalar>::digits > std::numeric_limits<TgtScalar>::digits)>
::type> {
45 TgtScalar
b = internal::random<TgtScalar>();
46 return static_cast<SrcScalar
>(b < TgtScalar(0) ? -(b + 1) : b);
51 template <
typename SrcScalar,
typename TgtScalar>
55 NumTraits<SrcScalar>::IsInteger && NumTraits<TgtScalar>::IsInteger && NumTraits<SrcScalar>::IsSigned &&
56 (std::numeric_limits<SrcScalar>::digits > std::numeric_limits<TgtScalar>::digits)>
::type> {
57 static SrcScalar
value() {
return static_cast<SrcScalar
>(internal::random<TgtScalar>()); }
61 template <
typename SrcScalar,
typename TgtScalar>
64 typename internal::
enable_if<NumTraits<SrcScalar>::IsInteger && NumTraits<TgtScalar>::IsInteger &&
65 !NumTraits<SrcScalar>::IsSigned && NumTraits<TgtScalar>::IsSigned &&
66 (std::numeric_limits<SrcScalar>::digits ==
67 std::numeric_limits<TgtScalar>::digits)>
::type> {
68 static SrcScalar
value() {
return internal::random<SrcScalar>() / 2; }
72 template <
typename SrcScalar,
typename TgtScalar>
76 !NumTraits<SrcScalar>::IsInteger && !NumTraits<SrcScalar>::IsComplex && NumTraits<TgtScalar>::IsInteger &&
77 (std::numeric_limits<TgtScalar>::digits <= std::numeric_limits<SrcScalar>::digits)>::type> {
78 static SrcScalar
value() {
return static_cast<SrcScalar
>(internal::random<TgtScalar>()); }
82 template <
typename SrcScalar,
typename TgtScalar>
86 !NumTraits<SrcScalar>::IsInteger && !NumTraits<SrcScalar>::IsComplex && NumTraits<TgtScalar>::IsInteger &&
87 (std::numeric_limits<TgtScalar>::digits > std::numeric_limits<SrcScalar>::digits)>
::type> {
92 static const TgtScalar KeepMask = (
static_cast<TgtScalar
>(1) << std::numeric_limits<SrcScalar>::digits) - 1;
93 const TgtScalar
a = internal::random<TgtScalar>();
94 return static_cast<SrcScalar
>(a > TgtScalar(0) ? (a & KeepMask) : -(a & KeepMask));
99 template <
typename SrcScalar,
typename TgtScalar>
101 SrcScalar, TgtScalar,
102 typename internal::
enable_if<NumTraits<SrcScalar>::IsInteger && !NumTraits<TgtScalar>::IsInteger &&
103 !NumTraits<TgtScalar>::IsComplex>
::type> {
110 template <
typename SrcScalar,
typename TgtScalar>
112 SrcScalar, TgtScalar,
113 typename internal::
enable_if<!NumTraits<SrcScalar>::IsInteger && !NumTraits<SrcScalar>::IsComplex &&
114 !NumTraits<TgtScalar>::IsInteger && !NumTraits<TgtScalar>::IsComplex &&
115 (std::numeric_limits<SrcScalar>::digits >
116 std::numeric_limits<TgtScalar>::digits)>
::type> {
117 static SrcScalar
value() {
return static_cast<SrcScalar
>(internal::random<TgtScalar>()); }
121 template <
typename SrcScalar,
typename TgtScalar>
123 SrcScalar, TgtScalar,
124 typename internal::
enable_if<NumTraits<SrcScalar>::IsComplex && !NumTraits<TgtScalar>::IsComplex>
::type> {
130 template <
typename SrcScalar,
typename TgtScalar>
132 SrcScalar, TgtScalar,
133 typename internal::
enable_if<!NumTraits<SrcScalar>::IsComplex && NumTraits<TgtScalar>::IsComplex>
::type> {
139 template <
typename SrcScalar,
typename TgtScalar>
141 SrcScalar, TgtScalar,
142 typename internal::
enable_if<NumTraits<SrcScalar>::IsComplex && NumTraits<TgtScalar>::IsComplex>
::type> {
NumTraits< SrcScalar >::Real SrcReal
NumTraits< TgtScalar >::Real TgtReal
Namespace containing all symbols from the Eigen library.
NumTraits< TgtScalar >::Real TgtReal
NumTraits< SrcScalar >::Real SrcReal