This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen
View | Details | Raw Unified | Return to bug 1257
Collapse All | Expand All

(-)a/Eigen/src/Core/MathFunctions.h (-21 / +22 lines)
Lines 243-281 struct conj_retval Link Here
243
* Implementation of abs2                                                 *
243
* Implementation of abs2                                                 *
244
****************************************************************************/
244
****************************************************************************/
245
245
246
template<typename Scalar,bool IsComplex>
246
template<typename Scalar,bool IsComplex>
247
struct abs2_impl_default
247
struct abs2_impl_default
248
{
248
{
249
  typedef typename NumTraits<Scalar>::Real RealScalar;
249
  typedef typename NumTraits<Scalar>::Real RealScalar;
250
  EIGEN_DEVICE_FUNC
250
  EIGEN_DEVICE_FUNC
251
  static inline RealScalar run(const Scalar& x)
251
  static inline EIGEN_CXX14_AUTO(RealScalar) run(const Scalar& x)
252
  {
252
  {
253
    return x*x;
253
    return x*x;
254
  }
254
  }
255
};
255
};
256
256
257
template<typename Scalar>
257
template<typename Scalar>
258
struct abs2_impl_default<Scalar, true> // IsComplex
258
struct abs2_impl_default<Scalar, true> // IsComplex
259
{
259
{
260
  typedef typename NumTraits<Scalar>::Real RealScalar;
260
  typedef typename NumTraits<Scalar>::Real RealScalar;
261
  EIGEN_DEVICE_FUNC
261
  EIGEN_DEVICE_FUNC
262
  static inline RealScalar run(const Scalar& x)
262
  static inline EIGEN_CXX14_AUTO(RealScalar) run(const Scalar& x)
263
  {
263
  {
264
    return real(x)*real(x) + imag(x)*imag(x);
264
    return real(x)*real(x) + imag(x)*imag(x);
265
  }
265
  }
266
};
266
};
267
267
268
template<typename Scalar>
268
template<typename Scalar>
269
struct abs2_impl
269
struct abs2_impl
270
{
270
{
271
  typedef typename NumTraits<Scalar>::Real RealScalar;
271
  typedef typename NumTraits<Scalar>::Real RealScalar;
272
  EIGEN_DEVICE_FUNC
272
  EIGEN_DEVICE_FUNC
273
  static inline RealScalar run(const Scalar& x)
273
  static inline EIGEN_CXX14_AUTO(RealScalar) run(const Scalar& x)
274
  {
274
  {
275
    return abs2_impl_default<Scalar,NumTraits<Scalar>::IsComplex>::run(x);
275
    return abs2_impl_default<Scalar,NumTraits<Scalar>::IsComplex>::run(x);
276
  }
276
  }
277
};
277
};
278
278
279
template<typename Scalar>
279
template<typename Scalar>
280
struct abs2_retval
280
struct abs2_retval
281
{
281
{
Lines 494-510 struct log1p_retval Link Here
494
* Implementation of pow                                                  *
494
* Implementation of pow                                                  *
495
****************************************************************************/
495
****************************************************************************/
496
496
497
template<typename ScalarX,typename ScalarY, bool IsInteger = NumTraits<ScalarX>::IsInteger&&NumTraits<ScalarY>::IsInteger>
497
template<typename ScalarX,typename ScalarY, bool IsInteger = NumTraits<ScalarX>::IsInteger&&NumTraits<ScalarY>::IsInteger>
498
struct pow_impl
498
struct pow_impl
499
{
499
{
500
  //typedef Scalar retval;
500
  //typedef Scalar retval;
501
  typedef typename ScalarBinaryOpTraits<ScalarX,ScalarY,internal::scalar_pow_op<ScalarX,ScalarY> >::ReturnType result_type;
501
  typedef typename ScalarBinaryOpTraits<ScalarX,ScalarY,internal::scalar_pow_op<ScalarX,ScalarY> >::ReturnType result_type;
502
  static EIGEN_DEVICE_FUNC inline result_type run(const ScalarX& x, const ScalarY& y)
502
  static EIGEN_DEVICE_FUNC inline EIGEN_CXX14_AUTO(result_type) run(const ScalarX& x, const ScalarY& y)
503
  {
503
  {
504
    EIGEN_USING_STD_MATH(pow);
504
    EIGEN_USING_STD_MATH(pow);
505
    return pow(x, y);
505
    return pow(x, y);
506
  }
506
  }
507
};
507
};
508
508
509
template<typename ScalarX,typename ScalarY>
509
template<typename ScalarX,typename ScalarY>
510
struct pow_impl<ScalarX,ScalarY, true>
510
struct pow_impl<ScalarX,ScalarY, true>
Lines 890-906 template<typename Scalar> Link Here
890
EIGEN_DEVICE_FUNC
890
EIGEN_DEVICE_FUNC
891
inline EIGEN_MATHFUNC_RETVAL(conj, Scalar) conj(const Scalar& x)
891
inline EIGEN_MATHFUNC_RETVAL(conj, Scalar) conj(const Scalar& x)
892
{
892
{
893
  return EIGEN_MATHFUNC_IMPL(conj, Scalar)::run(x);
893
  return EIGEN_MATHFUNC_IMPL(conj, Scalar)::run(x);
894
}
894
}
895
895
896
template<typename Scalar>
896
template<typename Scalar>
897
EIGEN_DEVICE_FUNC
897
EIGEN_DEVICE_FUNC
898
inline EIGEN_MATHFUNC_RETVAL(abs2, Scalar) abs2(const Scalar& x)
898
inline EIGEN_CXX14_AUTO(EIGEN_MATHFUNC_RETVAL(abs2, Scalar)) abs2(const Scalar& x)
899
{
899
{
900
  return EIGEN_MATHFUNC_IMPL(abs2, Scalar)::run(x);
900
  return EIGEN_MATHFUNC_IMPL(abs2, Scalar)::run(x);
901
}
901
}
902
902
903
template<typename Scalar>
903
template<typename Scalar>
904
EIGEN_DEVICE_FUNC
904
EIGEN_DEVICE_FUNC
905
inline EIGEN_MATHFUNC_RETVAL(norm1, Scalar) norm1(const Scalar& x)
905
inline EIGEN_MATHFUNC_RETVAL(norm1, Scalar) norm1(const Scalar& x)
906
{
906
{
Lines 918-934 template<typename Scalar> Link Here
918
EIGEN_DEVICE_FUNC
918
EIGEN_DEVICE_FUNC
919
inline EIGEN_MATHFUNC_RETVAL(log1p, Scalar) log1p(const Scalar& x)
919
inline EIGEN_MATHFUNC_RETVAL(log1p, Scalar) log1p(const Scalar& x)
920
{
920
{
921
  return EIGEN_MATHFUNC_IMPL(log1p, Scalar)::run(x);
921
  return EIGEN_MATHFUNC_IMPL(log1p, Scalar)::run(x);
922
}
922
}
923
923
924
template<typename ScalarX,typename ScalarY>
924
template<typename ScalarX,typename ScalarY>
925
EIGEN_DEVICE_FUNC
925
EIGEN_DEVICE_FUNC
926
inline typename internal::pow_impl<ScalarX,ScalarY>::result_type pow(const ScalarX& x, const ScalarY& y)
926
inline EIGEN_CXX14_AUTO(typename internal::pow_impl<ScalarX EIGEN_COMMA ScalarY>::result_type) pow(const ScalarX& x, const ScalarY& y)
927
{
927
{
928
  return internal::pow_impl<ScalarX,ScalarY>::run(x, y);
928
  return internal::pow_impl<ScalarX,ScalarY>::run(x, y);
929
}
929
}
930
930
931
template<typename T> EIGEN_DEVICE_FUNC bool (isnan)   (const T &x) { return internal::isnan_impl(x); }
931
template<typename T> EIGEN_DEVICE_FUNC bool (isnan)   (const T &x) { return internal::isnan_impl(x); }
932
template<typename T> EIGEN_DEVICE_FUNC bool (isinf)   (const T &x) { return internal::isinf_impl(x); }
932
template<typename T> EIGEN_DEVICE_FUNC bool (isinf)   (const T &x) { return internal::isinf_impl(x); }
933
template<typename T> EIGEN_DEVICE_FUNC bool (isfinite)(const T &x) { return internal::isfinite_impl(x); }
933
template<typename T> EIGEN_DEVICE_FUNC bool (isfinite)(const T &x) { return internal::isfinite_impl(x); }
934
934
Lines 936-968 template<typename Scalar> Link Here
936
EIGEN_DEVICE_FUNC
936
EIGEN_DEVICE_FUNC
937
inline EIGEN_MATHFUNC_RETVAL(round, Scalar) round(const Scalar& x)
937
inline EIGEN_MATHFUNC_RETVAL(round, Scalar) round(const Scalar& x)
938
{
938
{
939
  return EIGEN_MATHFUNC_IMPL(round, Scalar)::run(x);
939
  return EIGEN_MATHFUNC_IMPL(round, Scalar)::run(x);
940
}
940
}
941
941
942
template<typename T>
942
template<typename T>
943
EIGEN_DEVICE_FUNC
943
EIGEN_DEVICE_FUNC
944
T (floor)(const T& x)
944
EIGEN_CXX14_AUTO(T) (floor)(const T& x)
945
{
945
{
946
  EIGEN_USING_STD_MATH(floor);
946
  EIGEN_USING_STD_MATH(floor);
947
  return floor(x);
947
  return floor(x);
948
}
948
}
949
949
950
#ifdef __CUDACC__
950
#ifdef __CUDACC__
951
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
951
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
952
float floor(const float &x) { return ::floorf(x); }
952
float floor(const float &x) { return ::floorf(x); }
953
953
954
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
954
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
955
double floor(const double &x) { return ::floor(x); }
955
double floor(const double &x) { return ::floor(x); }
956
#endif
956
#endif
957
957
958
template<typename T>
958
template<typename T>
959
EIGEN_DEVICE_FUNC
959
EIGEN_DEVICE_FUNC
960
T (ceil)(const T& x)
960
EIGEN_CXX14_AUTO(T) (ceil)(const T& x)
961
{
961
{
962
  EIGEN_USING_STD_MATH(ceil);
962
  EIGEN_USING_STD_MATH(ceil);
963
  return ceil(x);
963
  return ceil(x);
964
}
964
}
965
965
966
#ifdef __CUDACC__
966
#ifdef __CUDACC__
967
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
967
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
968
float ceil(const float &x) { return ::ceilf(x); }
968
float ceil(const float &x) { return ::ceilf(x); }
Lines 992-1182 inline int log2(int x) Link Here
992
  * It is essentially equivalent to \code using std::sqrt; return sqrt(x); \endcode,
992
  * It is essentially equivalent to \code using std::sqrt; return sqrt(x); \endcode,
993
  * but slightly faster for float/double and some compilers (e.g., gcc), thanks to
993
  * but slightly faster for float/double and some compilers (e.g., gcc), thanks to
994
  * specializations when SSE is enabled.
994
  * specializations when SSE is enabled.
995
  *
995
  *
996
  * It's usage is justified in performance critical functions, like norm/normalize.
996
  * It's usage is justified in performance critical functions, like norm/normalize.
997
  */
997
  */
998
template<typename T>
998
template<typename T>
999
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
999
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1000
T sqrt(const T &x)
1000
EIGEN_CXX14_AUTO(T) sqrt(const T &x)
1001
{
1001
{
1002
  EIGEN_USING_STD_MATH(sqrt);
1002
  EIGEN_USING_STD_MATH(sqrt);
1003
  return sqrt(x);
1003
  return sqrt(x);
1004
}
1004
}
1005
1005
1006
template<typename T>
1006
template<typename T>
1007
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1007
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1008
T log(const T &x) {
1008
EIGEN_CXX14_AUTO(T) log(const T &x) {
1009
  EIGEN_USING_STD_MATH(log);
1009
  EIGEN_USING_STD_MATH(log);
1010
  return log(x);
1010
  return log(x);
1011
}
1011
}
1012
1012
1013
#ifdef __CUDACC__
1013
#ifdef __CUDACC__
1014
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1014
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1015
float log(const float &x) { return ::logf(x); }
1015
float log(const float &x) { return ::logf(x); }
1016
1016
1017
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1017
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1018
double log(const double &x) { return ::log(x); }
1018
double log(const double &x) { return ::log(x); }
1019
#endif
1019
#endif
1020
1020
1021
template<typename T>
1021
template<typename T>
1022
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1022
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1023
typename NumTraits<T>::Real abs(const T &x) {
1023
EIGEN_CXX14_AUTO(typename NumTraits<T>::Real)
1024
abs(const T &x) {
1024
  EIGEN_USING_STD_MATH(abs);
1025
  EIGEN_USING_STD_MATH(abs);
1025
  return abs(x);
1026
  return abs(x);
1026
}
1027
}
1027
1028
1028
#ifdef __CUDACC__
1029
#ifdef __CUDACC__
1029
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1030
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1030
float abs(const float &x) { return ::fabsf(x); }
1031
float abs(const float &x) { return ::fabsf(x); }
1031
1032
1032
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1033
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1033
double abs(const double &x) { return ::fabs(x); }
1034
double abs(const double &x) { return ::fabs(x); }
1034
#endif
1035
#endif
1035
1036
1036
template<typename T>
1037
template<typename T>
1037
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1038
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1038
T exp(const T &x) {
1039
EIGEN_CXX14_AUTO(T) exp(const T &x) {
1039
  EIGEN_USING_STD_MATH(exp);
1040
  EIGEN_USING_STD_MATH(exp);
1040
  return exp(x);
1041
  return exp(x);
1041
}
1042
}
1042
1043
1043
#ifdef __CUDACC__
1044
#ifdef __CUDACC__
1044
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1045
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1045
float exp(const float &x) { return ::expf(x); }
1046
float exp(const float &x) { return ::expf(x); }
1046
1047
1047
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1048
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1048
double exp(const double &x) { return ::exp(x); }
1049
double exp(const double &x) { return ::exp(x); }
1049
#endif
1050
#endif
1050
1051
1051
template<typename T>
1052
template<typename T>
1052
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1053
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1053
T cos(const T &x) {
1054
EIGEN_CXX14_AUTO(T) cos(const T &x) {
1054
  EIGEN_USING_STD_MATH(cos);
1055
  EIGEN_USING_STD_MATH(cos);
1055
  return cos(x);
1056
  return cos(x);
1056
}
1057
}
1057
1058
1058
#ifdef __CUDACC__
1059
#ifdef __CUDACC__
1059
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1060
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1060
float cos(const float &x) { return ::cosf(x); }
1061
float cos(const float &x) { return ::cosf(x); }
1061
1062
1062
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1063
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1063
double cos(const double &x) { return ::cos(x); }
1064
double cos(const double &x) { return ::cos(x); }
1064
#endif
1065
#endif
1065
1066
1066
template<typename T>
1067
template<typename T>
1067
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1068
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1068
T sin(const T &x) {
1069
EIGEN_CXX14_AUTO(T) sin(const T &x) {
1069
  EIGEN_USING_STD_MATH(sin);
1070
  EIGEN_USING_STD_MATH(sin);
1070
  return sin(x);
1071
  return sin(x);
1071
}
1072
}
1072
1073
1073
#ifdef __CUDACC__
1074
#ifdef __CUDACC__
1074
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1075
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1075
float sin(const float &x) { return ::sinf(x); }
1076
float sin(const float &x) { return ::sinf(x); }
1076
1077
1077
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1078
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1078
double sin(const double &x) { return ::sin(x); }
1079
double sin(const double &x) { return ::sin(x); }
1079
#endif
1080
#endif
1080
1081
1081
template<typename T>
1082
template<typename T>
1082
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1083
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1083
T tan(const T &x) {
1084
EIGEN_CXX14_AUTO(T) tan(const T &x) {
1084
  EIGEN_USING_STD_MATH(tan);
1085
  EIGEN_USING_STD_MATH(tan);
1085
  return tan(x);
1086
  return tan(x);
1086
}
1087
}
1087
1088
1088
#ifdef __CUDACC__
1089
#ifdef __CUDACC__
1089
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1090
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1090
float tan(const float &x) { return ::tanf(x); }
1091
float tan(const float &x) { return ::tanf(x); }
1091
1092
1092
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1093
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1093
double tan(const double &x) { return ::tan(x); }
1094
double tan(const double &x) { return ::tan(x); }
1094
#endif
1095
#endif
1095
1096
1096
template<typename T>
1097
template<typename T>
1097
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1098
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1098
T acos(const T &x) {
1099
EIGEN_CXX14_AUTO(T) acos(const T &x) {
1099
  EIGEN_USING_STD_MATH(acos);
1100
  EIGEN_USING_STD_MATH(acos);
1100
  return acos(x);
1101
  return acos(x);
1101
}
1102
}
1102
1103
1103
#ifdef __CUDACC__
1104
#ifdef __CUDACC__
1104
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1105
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1105
float acos(const float &x) { return ::acosf(x); }
1106
float acos(const float &x) { return ::acosf(x); }
1106
1107
1107
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1108
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1108
double acos(const double &x) { return ::acos(x); }
1109
double acos(const double &x) { return ::acos(x); }
1109
#endif
1110
#endif
1110
1111
1111
template<typename T>
1112
template<typename T>
1112
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1113
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1113
T asin(const T &x) {
1114
EIGEN_CXX14_AUTO(T) asin(const T &x) {
1114
  EIGEN_USING_STD_MATH(asin);
1115
  EIGEN_USING_STD_MATH(asin);
1115
  return asin(x);
1116
  return asin(x);
1116
}
1117
}
1117
1118
1118
#ifdef __CUDACC__
1119
#ifdef __CUDACC__
1119
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1120
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1120
float asin(const float &x) { return ::asinf(x); }
1121
float asin(const float &x) { return ::asinf(x); }
1121
1122
1122
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1123
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1123
double asin(const double &x) { return ::asin(x); }
1124
double asin(const double &x) { return ::asin(x); }
1124
#endif
1125
#endif
1125
1126
1126
template<typename T>
1127
template<typename T>
1127
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1128
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1128
T atan(const T &x) {
1129
EIGEN_CXX14_AUTO(T) atan(const T &x) {
1129
  EIGEN_USING_STD_MATH(atan);
1130
  EIGEN_USING_STD_MATH(atan);
1130
  return atan(x);
1131
  return atan(x);
1131
}
1132
}
1132
1133
1133
#ifdef __CUDACC__
1134
#ifdef __CUDACC__
1134
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1135
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1135
float atan(const float &x) { return ::atanf(x); }
1136
float atan(const float &x) { return ::atanf(x); }
1136
1137
1137
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1138
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1138
double atan(const double &x) { return ::atan(x); }
1139
double atan(const double &x) { return ::atan(x); }
1139
#endif
1140
#endif
1140
1141
1141
1142
1142
template<typename T>
1143
template<typename T>
1143
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1144
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1144
T cosh(const T &x) {
1145
EIGEN_CXX14_AUTO(T) cosh(const T &x) {
1145
  EIGEN_USING_STD_MATH(cosh);
1146
  EIGEN_USING_STD_MATH(cosh);
1146
  return cosh(x);
1147
  return cosh(x);
1147
}
1148
}
1148
1149
1149
#ifdef __CUDACC__
1150
#ifdef __CUDACC__
1150
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1151
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1151
float cosh(const float &x) { return ::coshf(x); }
1152
float cosh(const float &x) { return ::coshf(x); }
1152
1153
1153
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1154
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1154
double cosh(const double &x) { return ::cosh(x); }
1155
double cosh(const double &x) { return ::cosh(x); }
1155
#endif
1156
#endif
1156
1157
1157
template<typename T>
1158
template<typename T>
1158
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1159
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1159
T sinh(const T &x) {
1160
EIGEN_CXX14_AUTO(T) sinh(const T &x) {
1160
  EIGEN_USING_STD_MATH(sinh);
1161
  EIGEN_USING_STD_MATH(sinh);
1161
  return sinh(x);
1162
  return sinh(x);
1162
}
1163
}
1163
1164
1164
#ifdef __CUDACC__
1165
#ifdef __CUDACC__
1165
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1166
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1166
float sinh(const float &x) { return ::sinhf(x); }
1167
float sinh(const float &x) { return ::sinhf(x); }
1167
1168
1168
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1169
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1169
double sinh(const double &x) { return ::sinh(x); }
1170
double sinh(const double &x) { return ::sinh(x); }
1170
#endif
1171
#endif
1171
1172
1172
template<typename T>
1173
template<typename T>
1173
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1174
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1174
T tanh(const T &x) {
1175
EIGEN_CXX14_AUTO(T) tanh(const T &x) {
1175
  EIGEN_USING_STD_MATH(tanh);
1176
  EIGEN_USING_STD_MATH(tanh);
1176
  return tanh(x);
1177
  return tanh(x);
1177
}
1178
}
1178
1179
1179
#ifdef __CUDACC__
1180
#ifdef __CUDACC__
1180
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1181
template<> EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
1181
float tanh(const float &x) { return ::tanhf(x); }
1182
float tanh(const float &x) { return ::tanhf(x); }
1182
1183
(-)a/Eigen/src/Core/arch/CUDA/Half.h (-13 / +13 lines)
Lines 395-456 EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bo Link Here
395
#else
395
#else
396
  return (a.x & 0x7fff) > 0x7c00;
396
  return (a.x & 0x7fff) > 0x7c00;
397
#endif
397
#endif
398
}
398
}
399
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool (isfinite)(const Eigen::half& a) {
399
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool (isfinite)(const Eigen::half& a) {
400
  return !(Eigen::numext::isinf)(a) && !(Eigen::numext::isnan)(a);
400
  return !(Eigen::numext::isinf)(a) && !(Eigen::numext::isnan)(a);
401
}
401
}
402
402
403
template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half abs(const Eigen::half& a) {
403
template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC EIGEN_CXX14_AUTO(Eigen::half) abs(const Eigen::half& a) {
404
  Eigen::half result;
404
  Eigen::half result;
405
  result.x = a.x & 0x7FFF;
405
  result.x = a.x & 0x7FFF;
406
  return result;
406
  return result;
407
}
407
}
408
template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half exp(const Eigen::half& a) {
408
template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC EIGEN_CXX14_AUTO(Eigen::half) exp(const Eigen::half& a) {
409
  return Eigen::half(::expf(float(a)));
409
  return Eigen::half(::expf(float(a)));
410
}
410
}
411
template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half log(const Eigen::half& a) {
411
template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC EIGEN_CXX14_AUTO(Eigen::half) log(const Eigen::half& a) {
412
  return Eigen::half(::logf(float(a)));
412
  return Eigen::half(::logf(float(a)));
413
}
413
}
414
template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half sqrt(const Eigen::half& a) {
414
template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC EIGEN_CXX14_AUTO(Eigen::half) sqrt(const Eigen::half& a) {
415
  return Eigen::half(::sqrtf(float(a)));
415
  return Eigen::half(::sqrtf(float(a)));
416
}
416
}
417
template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half pow(const Eigen::half& a, const Eigen::half& b) {
417
template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC EIGEN_CXX14_AUTO(Eigen::half) pow(const Eigen::half& a, const Eigen::half& b) {
418
  return Eigen::half(::powf(float(a), float(b)));
418
  return Eigen::half(::powf(float(a), float(b)));
419
}
419
}
420
template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half sin(const Eigen::half& a) {
420
template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC EIGEN_CXX14_AUTO(Eigen::half) sin(const Eigen::half& a) {
421
  return Eigen::half(::sinf(float(a)));
421
  return Eigen::half(::sinf(float(a)));
422
}
422
}
423
template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half cos(const Eigen::half& a) {
423
template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC EIGEN_CXX14_AUTO(Eigen::half) cos(const Eigen::half& a) {
424
  return Eigen::half(::cosf(float(a)));
424
  return Eigen::half(::cosf(float(a)));
425
}
425
}
426
template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half tan(const Eigen::half& a) {
426
template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC EIGEN_CXX14_AUTO(Eigen::half) tan(const Eigen::half& a) {
427
  return Eigen::half(::tanf(float(a)));
427
  return Eigen::half(::tanf(float(a)));
428
}
428
}
429
template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half tanh(const Eigen::half& a) {
429
template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC EIGEN_CXX14_AUTO(Eigen::half) tanh(const Eigen::half& a) {
430
  return Eigen::half(::tanhf(float(a)));
430
  return Eigen::half(::tanhf(float(a)));
431
}
431
}
432
template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half floor(const Eigen::half& a) {
432
template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC EIGEN_CXX14_AUTO(Eigen::half) floor(const Eigen::half& a) {
433
  return Eigen::half(::floorf(float(a)));
433
  return Eigen::half(::floorf(float(a)));
434
}
434
}
435
template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half ceil(const Eigen::half& a) {
435
template<> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC EIGEN_CXX14_AUTO(Eigen::half) ceil(const Eigen::half& a) {
436
  return Eigen::half(::ceilf(float(a)));
436
  return Eigen::half(::ceilf(float(a)));
437
}
437
}
438
438
439
template <> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half mini(const Eigen::half& a, const Eigen::half& b) {
439
/*template <>*/ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half mini(const Eigen::half& a, const Eigen::half& b) {
440
#if defined(EIGEN_HAS_CUDA_FP16) && defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 530
440
#if defined(EIGEN_HAS_CUDA_FP16) && defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 530
441
  return __hlt(b, a) ? b : a;
441
  return __hlt(b, a) ? b : a;
442
#else
442
#else
443
  const float f1 = static_cast<float>(a);
443
  const float f1 = static_cast<float>(a);
444
  const float f2 = static_cast<float>(b);
444
  const float f2 = static_cast<float>(b);
445
  return f2 < f1 ? b : a;
445
  return f2 < f1 ? b : a;
446
#endif
446
#endif
447
}
447
}
448
template <> EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half maxi(const Eigen::half& a, const Eigen::half& b) {
448
/*template <>*/ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half maxi(const Eigen::half& a, const Eigen::half& b) {
449
#if defined(EIGEN_HAS_CUDA_FP16) && defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 530
449
#if defined(EIGEN_HAS_CUDA_FP16) && defined(__CUDA_ARCH__) && __CUDA_ARCH__ >= 530
450
  return __hlt(a, b) ? b : a;
450
  return __hlt(a, b) ? b : a;
451
#else
451
#else
452
  const float f1 = static_cast<float>(a);
452
  const float f1 = static_cast<float>(a);
453
  const float f2 = static_cast<float>(b);
453
  const float f2 = static_cast<float>(b);
454
  return f1 < f2 ? b : a;
454
  return f1 < f2 ? b : a;
455
#endif
455
#endif
456
}
456
}
(-)a/Eigen/src/Core/arch/SSE/MathFunctions.h (-2 / +2 lines)
Lines 566-589 ptanh<Packet4f>(const Packet4f& _x) { Link Here
566
}
566
}
567
567
568
} // end namespace internal
568
} // end namespace internal
569
569
570
namespace numext {
570
namespace numext {
571
571
572
template<>
572
template<>
573
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
573
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
574
float sqrt(const float &x)
574
EIGEN_CXX14_AUTO(float) sqrt(const float &x)
575
{
575
{
576
  return internal::pfirst(internal::Packet4f(_mm_sqrt_ss(_mm_set_ss(x))));
576
  return internal::pfirst(internal::Packet4f(_mm_sqrt_ss(_mm_set_ss(x))));
577
}
577
}
578
578
579
template<>
579
template<>
580
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
580
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
581
double sqrt(const double &x)
581
EIGEN_CXX14_AUTO(double) sqrt(const double &x)
582
{
582
{
583
#if EIGEN_COMP_GNUC_STRICT
583
#if EIGEN_COMP_GNUC_STRICT
584
  // This works around a GCC bug generating poor code for _mm_sqrt_pd
584
  // This works around a GCC bug generating poor code for _mm_sqrt_pd
585
  // See https://bitbucket.org/eigen/eigen/commits/14f468dba4d350d7c19c9b93072e19f7b3df563b
585
  // See https://bitbucket.org/eigen/eigen/commits/14f468dba4d350d7c19c9b93072e19f7b3df563b
586
  return internal::pfirst(internal::Packet2d(__builtin_ia32_sqrtsd(_mm_set_sd(x))));
586
  return internal::pfirst(internal::Packet2d(__builtin_ia32_sqrtsd(_mm_set_sd(x))));
587
#else
587
#else
588
  return internal::pfirst(internal::Packet2d(_mm_sqrt_pd(_mm_set_sd(x))));
588
  return internal::pfirst(internal::Packet2d(_mm_sqrt_pd(_mm_set_sd(x))));
589
#endif
589
#endif
(-)a/Eigen/src/Core/util/Macros.h (+16 lines)
Lines 451-466 Link Here
451
      || ((__cplusplus >= 201103L) && (EIGEN_COMP_GNUC_STRICT || EIGEN_COMP_CLANG || EIGEN_COMP_ICC>=1400)) \
451
      || ((__cplusplus >= 201103L) && (EIGEN_COMP_GNUC_STRICT || EIGEN_COMP_CLANG || EIGEN_COMP_ICC>=1400)) \
452
      || EIGEN_COMP_MSVC >= 1900)
452
      || EIGEN_COMP_MSVC >= 1900)
453
    #define EIGEN_HAS_CXX11_NOEXCEPT 1
453
    #define EIGEN_HAS_CXX11_NOEXCEPT 1
454
  #else
454
  #else
455
    #define EIGEN_HAS_CXX11_NOEXCEPT 0
455
    #define EIGEN_HAS_CXX11_NOEXCEPT 0
456
  #endif
456
  #endif
457
#endif
457
#endif
458
458
459
// Does the compiler support variadic templates?
460
#ifndef EIGEN_HAS_CXX14
461
#if EIGEN_MAX_CPP_VER>=14 && __cplusplus >= 201402L
462
#define EIGEN_HAS_CXX14 1
463
#else
464
#define EIGEN_HAS_CXX14 0
465
#endif
466
#endif
467
468
// This macro outputs auto if c++14 is available, and DEFAULT_TYPE otherwise
469
#if EIGEN_HAS_CXX14
470
#define EIGEN_CXX14_AUTO(DEFAULT_TYPE) auto
471
#else
472
#define EIGEN_CXX14_AUTO(DEFAULT_TYPE) DEFAULT_TYPE
473
#endif
474
459
/** Allows to disable some optimizations which might affect the accuracy of the result.
475
/** Allows to disable some optimizations which might affect the accuracy of the result.
460
  * Such optimization are enabled by default, and set EIGEN_FAST_MATH to 0 to disable them.
476
  * Such optimization are enabled by default, and set EIGEN_FAST_MATH to 0 to disable them.
461
  * They currently include:
477
  * They currently include:
462
  *   - single precision ArrayBase::sin() and ArrayBase::cos() for SSE and AVX vectorization.
478
  *   - single precision ArrayBase::sin() and ArrayBase::cos() for SSE and AVX vectorization.
463
  */
479
  */
464
#ifndef EIGEN_FAST_MATH
480
#ifndef EIGEN_FAST_MATH
465
#define EIGEN_FAST_MATH 1
481
#define EIGEN_FAST_MATH 1
466
#endif
482
#endif
(-)a/Eigen/src/SVD/BDCSVD.h (-1 / +1 lines)
Lines 1047-1063 void BDCSVD<MatrixType>::deflation(Index Link Here
1047
  const Index length = lastCol + 1 - firstCol;
1047
  const Index length = lastCol + 1 - firstCol;
1048
  
1048
  
1049
  Block<MatrixXr,Dynamic,1> col0(m_computed, firstCol+shift, firstCol+shift, length, 1);
1049
  Block<MatrixXr,Dynamic,1> col0(m_computed, firstCol+shift, firstCol+shift, length, 1);
1050
  Diagonal<MatrixXr> fulldiag(m_computed);
1050
  Diagonal<MatrixXr> fulldiag(m_computed);
1051
  VectorBlock<Diagonal<MatrixXr>,Dynamic> diag(fulldiag, firstCol+shift, length);
1051
  VectorBlock<Diagonal<MatrixXr>,Dynamic> diag(fulldiag, firstCol+shift, length);
1052
  
1052
  
1053
  const RealScalar considerZero = (std::numeric_limits<RealScalar>::min)();
1053
  const RealScalar considerZero = (std::numeric_limits<RealScalar>::min)();
1054
  RealScalar maxDiag = diag.tail((std::max)(Index(1),length-1)).cwiseAbs().maxCoeff();
1054
  RealScalar maxDiag = diag.tail((std::max)(Index(1),length-1)).cwiseAbs().maxCoeff();
1055
  RealScalar epsilon_strict = numext::maxi(considerZero,NumTraits<RealScalar>::epsilon() * maxDiag);
1055
  RealScalar epsilon_strict = numext::maxi<RealScalar>(considerZero,NumTraits<RealScalar>::epsilon() * maxDiag);
1056
  RealScalar epsilon_coarse = 8 * NumTraits<RealScalar>::epsilon() * numext::maxi<RealScalar>(col0.cwiseAbs().maxCoeff(), maxDiag);
1056
  RealScalar epsilon_coarse = 8 * NumTraits<RealScalar>::epsilon() * numext::maxi<RealScalar>(col0.cwiseAbs().maxCoeff(), maxDiag);
1057
  
1057
  
1058
#ifdef EIGEN_BDCSVD_SANITY_CHECKS
1058
#ifdef EIGEN_BDCSVD_SANITY_CHECKS
1059
  assert(m_naiveU.allFinite());
1059
  assert(m_naiveU.allFinite());
1060
  assert(m_naiveV.allFinite());
1060
  assert(m_naiveV.allFinite());
1061
  assert(m_computed.allFinite());
1061
  assert(m_computed.allFinite());
1062
#endif
1062
#endif
1063
1063
(-)a/Eigen/src/SVD/JacobiSVD.h (-1 / +1 lines)
Lines 722-738 JacobiSVD<MatrixType, QRPreconditioner>: Link Here
722
            // accumulate resulting Jacobi rotations
722
            // accumulate resulting Jacobi rotations
723
            m_workMatrix.applyOnTheLeft(p,q,j_left);
723
            m_workMatrix.applyOnTheLeft(p,q,j_left);
724
            if(computeU()) m_matrixU.applyOnTheRight(p,q,j_left.transpose());
724
            if(computeU()) m_matrixU.applyOnTheRight(p,q,j_left.transpose());
725
725
726
            m_workMatrix.applyOnTheRight(p,q,j_right);
726
            m_workMatrix.applyOnTheRight(p,q,j_right);
727
            if(computeV()) m_matrixV.applyOnTheRight(p,q,j_right);
727
            if(computeV()) m_matrixV.applyOnTheRight(p,q,j_right);
728
728
729
            // keep track of the largest diagonal coefficient
729
            // keep track of the largest diagonal coefficient
730
            maxDiagEntry = numext::maxi(maxDiagEntry,numext::maxi(abs(m_workMatrix.coeff(p,p)), abs(m_workMatrix.coeff(q,q))));
730
            maxDiagEntry = numext::maxi<RealScalar>(maxDiagEntry,numext::maxi(abs(m_workMatrix.coeff(p,p)), abs(m_workMatrix.coeff(q,q))));
731
          }
731
          }
732
        }
732
        }
733
      }
733
      }
734
    }
734
    }
735
  }
735
  }
736
736
737
  /*** step 3. The work matrix is now diagonal, so ensure it's positive so its diagonal entries are the singular values ***/
737
  /*** step 3. The work matrix is now diagonal, so ensure it's positive so its diagonal entries are the singular values ***/
738
738
(-)a/Eigen/src/SVD/SVDBase.h (-2 / +1 lines)
Lines 125-144 public: Link Here
125
    *
125
    *
126
    * \note This method has to determine which singular values should be considered nonzero.
126
    * \note This method has to determine which singular values should be considered nonzero.
127
    *       For that, it uses the threshold value that you can control by calling
127
    *       For that, it uses the threshold value that you can control by calling
128
    *       setThreshold(const RealScalar&).
128
    *       setThreshold(const RealScalar&).
129
    */
129
    */
130
  inline Index rank() const
130
  inline Index rank() const
131
  {
131
  {
132
    using std::abs;
132
    using std::abs;
133
    using std::max;
134
    eigen_assert(m_isInitialized && "JacobiSVD is not initialized.");
133
    eigen_assert(m_isInitialized && "JacobiSVD is not initialized.");
135
    if(m_singularValues.size()==0) return 0;
134
    if(m_singularValues.size()==0) return 0;
136
    RealScalar premultiplied_threshold = (max)(m_singularValues.coeff(0) * threshold(), (std::numeric_limits<RealScalar>::min)());
135
    RealScalar premultiplied_threshold = numext::maxi<RealScalar>(m_singularValues.coeff(0) * threshold(), (std::numeric_limits<RealScalar>::min)());
137
    Index i = m_nonzeroSingularValues-1;
136
    Index i = m_nonzeroSingularValues-1;
138
    while(i>=0 && m_singularValues.coeff(i) < premultiplied_threshold) --i;
137
    while(i>=0 && m_singularValues.coeff(i) < premultiplied_threshold) --i;
139
    return i+1;
138
    return i+1;
140
  }
139
  }
141
  
140
  
142
  /** Allows to prescribe a threshold to be used by certain methods, such as rank() and solve(),
141
  /** Allows to prescribe a threshold to be used by certain methods, such as rank() and solve(),
143
    * which need to determine when singular values are to be considered nonzero.
142
    * which need to determine when singular values are to be considered nonzero.
144
    * This is not used for the SVD decomposition itself.
143
    * This is not used for the SVD decomposition itself.
(-)a/test/boostmultiprec.cpp (-1 / +1 lines)
Lines 54-70 Link Here
54
#undef isnan
54
#undef isnan
55
#undef isinf
55
#undef isinf
56
#undef isfinite
56
#undef isfinite
57
57
58
#include <boost/multiprecision/cpp_dec_float.hpp>
58
#include <boost/multiprecision/cpp_dec_float.hpp>
59
#include <boost/multiprecision/number.hpp>
59
#include <boost/multiprecision/number.hpp>
60
60
61
namespace mp = boost::multiprecision;
61
namespace mp = boost::multiprecision;
62
typedef mp::number<mp::cpp_dec_float<100>, mp::et_off> Real; // swith to et_on for testing with expression templates
62
typedef mp::number<mp::cpp_dec_float<100>, mp::et_on> Real; // swith to et_on for testing with expression templates
63
63
64
namespace Eigen {
64
namespace Eigen {
65
  template<> struct NumTraits<Real> : GenericNumTraits<Real> {
65
  template<> struct NumTraits<Real> : GenericNumTraits<Real> {
66
    static inline Real dummy_precision() { return 1e-50; }
66
    static inline Real dummy_precision() { return 1e-50; }
67
  };
67
  };
68
68
69
  template<typename T1,typename T2,typename T3,typename T4,typename T5>
69
  template<typename T1,typename T2,typename T3,typename T4,typename T5>
70
  struct NumTraits<boost::multiprecision::detail::expression<T1,T2,T3,T4,T5> > : NumTraits<Real> {};
70
  struct NumTraits<boost::multiprecision::detail::expression<T1,T2,T3,T4,T5> > : NumTraits<Real> {};
(-)a/test/eigensolver_selfadjoint.cpp (-1 / +1 lines)
Lines 14-30 Link Here
14
#include <Eigen/Eigenvalues>
14
#include <Eigen/Eigenvalues>
15
#include <Eigen/SparseCore>
15
#include <Eigen/SparseCore>
16
16
17
17
18
template<typename MatrixType> void selfadjointeigensolver_essential_check(const MatrixType& m)
18
template<typename MatrixType> void selfadjointeigensolver_essential_check(const MatrixType& m)
19
{
19
{
20
  typedef typename MatrixType::Scalar Scalar;
20
  typedef typename MatrixType::Scalar Scalar;
21
  typedef typename NumTraits<Scalar>::Real RealScalar;
21
  typedef typename NumTraits<Scalar>::Real RealScalar;
22
  RealScalar eival_eps = (std::min)(test_precision<RealScalar>(),  NumTraits<Scalar>::dummy_precision()*20000);
22
  RealScalar eival_eps = numext::mini<RealScalar>(test_precision<RealScalar>(),  NumTraits<Scalar>::dummy_precision()*20000);
23
  
23
  
24
  SelfAdjointEigenSolver<MatrixType> eiSymm(m);
24
  SelfAdjointEigenSolver<MatrixType> eiSymm(m);
25
  VERIFY_IS_EQUAL(eiSymm.info(), Success);
25
  VERIFY_IS_EQUAL(eiSymm.info(), Success);
26
  VERIFY_IS_APPROX(m.template selfadjointView<Lower>() * eiSymm.eigenvectors(),
26
  VERIFY_IS_APPROX(m.template selfadjointView<Lower>() * eiSymm.eigenvectors(),
27
                   eiSymm.eigenvectors() * eiSymm.eigenvalues().asDiagonal());
27
                   eiSymm.eigenvectors() * eiSymm.eigenvalues().asDiagonal());
28
  VERIFY_IS_APPROX(m.template selfadjointView<Lower>().eigenvalues(), eiSymm.eigenvalues());
28
  VERIFY_IS_APPROX(m.template selfadjointView<Lower>().eigenvalues(), eiSymm.eigenvalues());
29
  VERIFY_IS_UNITARY(eiSymm.eigenvectors());
29
  VERIFY_IS_UNITARY(eiSymm.eigenvectors());
30
30
(-)a/test/qr.cpp (-1 / +1 lines)
Lines 81-97 template<typename MatrixType> void qr_in Link Here
81
  for(int i = 0; i < size; i++) m1(i,i) = internal::random<Scalar>();
81
  for(int i = 0; i < size; i++) m1(i,i) = internal::random<Scalar>();
82
  RealScalar absdet = abs(m1.diagonal().prod());
82
  RealScalar absdet = abs(m1.diagonal().prod());
83
  m3 = qr.householderQ(); // get a unitary
83
  m3 = qr.householderQ(); // get a unitary
84
  m1 = m3 * m1 * m3;
84
  m1 = m3 * m1 * m3;
85
  qr.compute(m1);
85
  qr.compute(m1);
86
  VERIFY_IS_APPROX(log(absdet), qr.logAbsDeterminant());
86
  VERIFY_IS_APPROX(log(absdet), qr.logAbsDeterminant());
87
  // This test is tricky if the determinant becomes too small.
87
  // This test is tricky if the determinant becomes too small.
88
  // Since we generate random numbers with magnitude rrange [0,1], the average determinant is 0.5^size
88
  // Since we generate random numbers with magnitude rrange [0,1], the average determinant is 0.5^size
89
  VERIFY_IS_MUCH_SMALLER_THAN( abs(absdet-qr.absDeterminant()), (max)(RealScalar(pow(0.5,size)),(max)(abs(absdet),abs(qr.absDeterminant()))) );
89
  VERIFY_IS_MUCH_SMALLER_THAN( abs(absdet-qr.absDeterminant()), numext::maxi(RealScalar(pow(0.5,size)),numext::maxi<RealScalar>(abs(absdet),abs(qr.absDeterminant()))) );
90
  
90
  
91
}
91
}
92
92
93
template<typename MatrixType> void qr_verify_assert()
93
template<typename MatrixType> void qr_verify_assert()
94
{
94
{
95
  MatrixType tmp;
95
  MatrixType tmp;
96
96
97
  HouseholderQR<MatrixType> qr;
97
  HouseholderQR<MatrixType> qr;

Return to bug 1257