45 #ifndef JIXIE_SVD_TOOLS_H
46 #define JIXIE_SVD_TOOLS_H
48 #pragma GCC diagnostic push
49 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
50 #include <Eigen/Dense>
53 #pragma GCC diagnostic pop
56 #include <xmmintrin.h>
71 std::mt19937 generator;
87 std::uniform_real_distribution<T> distribution(a, b);
88 return distribution(generator);
94 template <
class Derived>
95 void fill(Eigen::DenseBase<Derived>& x, T a, T b)
97 for (
typename Derived::Index i = 0; i < x.size(); i++)
102 namespace MATH_TOOLS {
110 inline float approx_rsqrt(
float a)
112 return _mm_cvtss_f32(_mm_rsqrt_ss(_mm_set_ss(a)));
119 inline float rsqrt(
float a)
121 return (
float)1.0f / std::sqrt(a);
133 inline double rsqrt(
double a)
154 start_time = std::chrono::steady_clock::now();
162 to_time = std::chrono::steady_clock::now();
163 elapsed_seconds = to_time - start_time;
164 start_time = to_time;
165 return elapsed_seconds.count();
169 std::chrono::time_point<std::chrono::steady_clock> start_time;
170 std::chrono::time_point<std::chrono::steady_clock> to_time;
171 std::chrono::duration<double> elapsed_seconds;
176 template <
class T,
class Enable =
void>
178 using type =
typename T::Scalar;
187 using ScalarType =
typename INTERNAL::ScalarTypeHelper<T>::type;
189 template <
class MatrixType>
190 constexpr
bool isSize(
int m,
int n)
192 return MatrixType::RowsAtCompileTime == m && MatrixType::ColsAtCompileTime == n;
Follow us!