merged AI doc, some new pages
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
/*! \file pimathcomplex.h
|
||||
* \ingroup Math
|
||||
* \~\brief
|
||||
* \~english Complex numbers
|
||||
* \~russian Комплексные числа
|
||||
*/
|
||||
//! \~\file pimathcomplex.h
|
||||
//! \~\ingroup Math
|
||||
//! \~\brief
|
||||
//! \~english Complex numbers
|
||||
//! \~russian Комплексные числа
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
PIP math complex
|
||||
@@ -36,27 +35,57 @@
|
||||
|
||||
using std::complex;
|
||||
|
||||
//! \~\ingroup Math
|
||||
//! \~english Type trait that reports whether \a T is a specialization of \c std::complex.
|
||||
//! \~russian Признак типа, определяющий, является ли \a T специализацией \c std::complex.
|
||||
template<typename T>
|
||||
struct is_complex: std::false_type {};
|
||||
|
||||
//! \~\ingroup Math
|
||||
//! \~english Specialization for complex types.
|
||||
//! \~russian Специализация для комплексных типов.
|
||||
template<typename T>
|
||||
struct is_complex<std::complex<T>>: std::true_type {};
|
||||
|
||||
//! \~english Complex integer type.
|
||||
//! \~russian Комплексный тип на целых числах.
|
||||
typedef complex<int> complexi;
|
||||
//! \~english Complex short integer type.
|
||||
//! \~russian Комплексный тип на \c short.
|
||||
typedef complex<short> complexs;
|
||||
//! \~english Complex single-precision type.
|
||||
//! \~russian Комплексный тип одинарной точности.
|
||||
typedef complex<float> complexf;
|
||||
//! \~english Complex extended-precision type.
|
||||
//! \~russian Комплексный тип расширенной точности.
|
||||
typedef complex<ldouble> complexld;
|
||||
#ifndef QPIEVALUATOR_COMPLEX
|
||||
//! \~english Complex double-precision type.
|
||||
//! \~russian Комплексный тип двойной точности.
|
||||
typedef complex<double> complexd;
|
||||
|
||||
//! \~english Imaginary unit in double precision.
|
||||
//! \~russian Мнимая единица двойной точности.
|
||||
const complexd complexd_i(0., 1.);
|
||||
//! \~english Zero value in double precision.
|
||||
//! \~russian Нулевое значение двойной точности.
|
||||
const complexd complexd_0(0.);
|
||||
//! \~english Unity value in double precision.
|
||||
//! \~russian Единичное значение двойной точности.
|
||||
const complexd complexd_1(1.);
|
||||
#endif
|
||||
//! \~english Imaginary unit in extended precision.
|
||||
//! \~russian Мнимая единица расширенной точности.
|
||||
const complexld complexld_i(0., 1.);
|
||||
//! \~english Zero value in extended precision.
|
||||
//! \~russian Нулевое значение расширенной точности.
|
||||
const complexld complexld_0(0.);
|
||||
//! \~english Unity value in extended precision.
|
||||
//! \~russian Единичное значение расширенной точности.
|
||||
const complexld complexld_1(1.);
|
||||
|
||||
//! \~english Returns sign for real and imaginary parts independently.
|
||||
//! \~russian Возвращает знак действительной и мнимой частей по отдельности.
|
||||
inline complexd sign(const complexd & x) {
|
||||
return complexd(sign(x.real()), sign(x.imag()));
|
||||
}
|
||||
@@ -103,6 +132,9 @@ inline complexd log10(const complexd & c) {
|
||||
# endif
|
||||
#endif
|
||||
|
||||
//! \relatesalso PICout
|
||||
//! \~english Writes a complex number as `(real; imag)`.
|
||||
//! \~russian Записывает комплексное число в виде `(real; imag)`.
|
||||
template<typename T>
|
||||
inline PICout operator<<(PICout s, const complex<T> & v) {
|
||||
s.space();
|
||||
@@ -113,6 +145,8 @@ inline PICout operator<<(PICout s, const complex<T> & v) {
|
||||
}
|
||||
|
||||
|
||||
//! \~english Returns magnitudes of all complex elements in the vector.
|
||||
//! \~russian Возвращает модули всех комплексных элементов вектора.
|
||||
inline PIVector<double> abs(const PIVector<complexd> & v) {
|
||||
PIVector<double> result;
|
||||
result.resize(v.size());
|
||||
@@ -122,6 +156,8 @@ inline PIVector<double> abs(const PIVector<complexd> & v) {
|
||||
}
|
||||
|
||||
|
||||
//! \~english Returns element-wise magnitudes of a complex matrix.
|
||||
//! \~russian Возвращает матрицу модулей для комплексной матрицы.
|
||||
inline PIVector2D<double> abs(const PIVector2D<complexd> & v) {
|
||||
PIVector2D<double> result(v.rows(), v.cols());
|
||||
for (uint i = 0; i < v.rows(); i++)
|
||||
@@ -131,24 +167,16 @@ inline PIVector2D<double> abs(const PIVector2D<complexd> & v) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief floating point number specific comparison between value passed as parameter and zero
|
||||
*
|
||||
* @param v floating point parameter for comparison
|
||||
* @return true if v in locality of zero, otherwise false
|
||||
*/
|
||||
//! \~english Checks whether a floating-point value is close to zero.
|
||||
//! \~russian Проверяет, находится ли вещественное значение вблизи нуля.
|
||||
template<typename T, typename std::enable_if<std::is_floating_point<T>::value, int>::type = 0>
|
||||
inline bool PIMathFloatNullCompare(const T v) {
|
||||
static_assert(std::is_floating_point<T>::value, "Type must be floating point");
|
||||
return (piAbs(v) < T(1E-200));
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief floating point number specific comparison between parameter value and zero.
|
||||
*
|
||||
* @param v complex with floating point real and imag parts
|
||||
* @return true if absolute of v in locality of zero, otherwise false
|
||||
*/
|
||||
//! \~english Checks whether a complex value with floating-point components is close to zero.
|
||||
//! \~russian Проверяет, находится ли комплексное значение с вещественными компонентами вблизи нуля.
|
||||
template<typename T,
|
||||
typename std::enable_if<std::is_floating_point<decltype(T::real)>::value && std::is_floating_point<decltype(T::imag)>::value,
|
||||
int>::type = 0>
|
||||
|
||||
Reference in New Issue
Block a user