// This file is part of Eigen, a lightweight C++ template library // for linear algebra. // // Copyright (C) 2017 Gael Guennebaud <gael.guennebaud@inria.fr> // // This Source Code Form is subject to the terms of the Mozilla // Public License v. 2.0. If a copy of the MPL was not distributed // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
for(int k=0; k<100; ++k)
{
T x = internal::random<T>();
Real y = numext::arg(x);
VERIFY_IS_APPROX( y, std::arg(x) );
}
}
template<typename T> struct check_sqrt_impl { staticvoid run() { for (int i=0; i<1000; ++i) { const T x = numext::abs(internal::random<T>()); const T sqrtx = numext::sqrt(x);
VERIFY_IS_APPROX(sqrtx*sqrtx, x);
}
// Corner cases. const T zero = T(0); const T one = T(1); const T inf = std::numeric_limits<T>::infinity(); const T nan = std::numeric_limits<T>::quiet_NaN();
VERIFY_IS_EQUAL(numext::sqrt(zero), zero);
VERIFY_IS_EQUAL(numext::sqrt(inf), inf);
VERIFY((numext::isnan)(numext::sqrt(nan)));
VERIFY((numext::isnan)(numext::sqrt(-one)));
}
};
for (int i=0; i<1000; ++i) { const ComplexT x = internal::random<ComplexT>(); const ComplexT sqrtx = numext::sqrt(x);
VERIFY_IS_APPROX(sqrtx*sqrtx, x);
}
// Corner cases. const T zero = T(0); const T one = T(1); const T inf = std::numeric_limits<T>::infinity(); const T nan = std::numeric_limits<T>::quiet_NaN();
template<typename T> struct check_rsqrt_impl { staticvoid run() { const T zero = T(0); const T one = T(1); const T inf = std::numeric_limits<T>::infinity(); const T nan = std::numeric_limits<T>::quiet_NaN();
for (int i=0; i<1000; ++i) { const T x = numext::abs(internal::random<T>()); const T rsqrtx = numext::rsqrt(x); const T invx = one / x;
VERIFY_IS_APPROX(rsqrtx*rsqrtx, invx);
}
template<typename T> struct check_rsqrt_impl<std::complex<T> > { staticvoid run() { typedeftypename std::complex<T> ComplexT; const T zero = T(0); const T one = T(1); const T inf = std::numeric_limits<T>::infinity(); const T nan = std::numeric_limits<T>::quiet_NaN();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.