📄 traits.hpp
字号:
return std::sqrt (t);
}
static
BOOST_UBLAS_INLINE
real_type norm_1 (const_reference t) {
// Oops, should have known that!
return type_traits<real_type>::abs (self_type::real (t)) +
type_traits<real_type>::abs (self_type::imag (t));
}
static
BOOST_UBLAS_INLINE
real_type norm_2 (const_reference t) {
return self_type::abs (t);
}
static
BOOST_UBLAS_INLINE
real_type norm_inf (const_reference t) {
// Oops, should have known that!
return std::max (type_traits<real_type>::abs (self_type::real (t)),
type_traits<real_type>::abs (self_type::imag (t)));
}
static
BOOST_UBLAS_INLINE
bool equals (const_reference t1, const_reference t2) {
return self_type::norm_inf (t1 - t2) < BOOST_UBLAS_TYPE_CHECK_EPSILON *
std::max (std::max (self_type::norm_inf (t1),
self_type::norm_inf (t2)),
BOOST_UBLAS_TYPE_CHECK_MIN);
}
};
template<>
struct type_traits<std::complex<double> > {
typedef type_traits<std::complex<double> > self_type;
typedef std::complex<double> value_type;
typedef const std::complex<double> &const_reference;
typedef std::complex<double> &reference;
typedef double real_type;
#ifndef BOOST_UBLAS_USE_LONG_DOUBLE
typedef std::complex<double> precision_type;
#else
typedef std::complex<long double> precision_type;
#endif
BOOST_STATIC_CONSTANT (std::size_t, plus_complexity = 2);
BOOST_STATIC_CONSTANT (std::size_t, multiplies_complexity = 6);
static
BOOST_UBLAS_INLINE
real_type real (const_reference t) {
// return t.real ();
return std::real (t);
}
static
BOOST_UBLAS_INLINE
real_type imag (const_reference t) {
// return t.imag ();
return std::imag (t);
}
static
BOOST_UBLAS_INLINE
value_type conj (const_reference t) {
// return t.conj ();
return std::conj (t);
}
static
BOOST_UBLAS_INLINE
real_type abs (const_reference t) {
return std::abs (t);
}
static
BOOST_UBLAS_INLINE
value_type sqrt (const_reference t) {
return std::sqrt (t);
}
static
BOOST_UBLAS_INLINE
real_type norm_1 (const_reference t) {
// Oops, should have known that!
return type_traits<real_type>::abs (self_type::real (t)) +
type_traits<real_type>::abs (self_type::imag (t));
}
static
BOOST_UBLAS_INLINE
real_type norm_2 (const_reference t) {
return self_type::abs (t);
}
static
BOOST_UBLAS_INLINE
real_type norm_inf (const_reference t) {
// Oops, should have known that!
return std::max (type_traits<real_type>::abs (self_type::real (t)),
type_traits<real_type>::abs (self_type::imag (t)));
}
static
BOOST_UBLAS_INLINE
bool equals (const_reference t1, const_reference t2) {
return self_type::norm_inf (t1 - t2) < BOOST_UBLAS_TYPE_CHECK_EPSILON *
std::max (std::max (self_type::norm_inf (t1),
self_type::norm_inf (t2)),
BOOST_UBLAS_TYPE_CHECK_MIN);
}
};
#ifdef BOOST_UBLAS_USE_LONG_DOUBLE
template<>
struct type_traits<std::complex<long double> > {
typedef type_traits<std::complex<long double> > self_type;
typedef std::complex<long double> value_type;
typedef const std::complex<long double> &const_reference;
typedef std::complex<long double> &reference;
typedef long double real_type;
typedef std::complex<long double> precision_type;
BOOST_STATIC_CONSTANT (std::size_t, plus_complexity = 2);
BOOST_STATIC_CONSTANT (std::size_t, multiplies_complexity = 6);
static
BOOST_UBLAS_INLINE
real_type real (const_reference t) {
// return t.real ();
return std::real (t);
}
static
BOOST_UBLAS_INLINE
real_type imag (const_reference t) {
// return t.imag ();
return std::imag (t);
}
static
BOOST_UBLAS_INLINE
value_type conj (const_reference t) {
// return t.conj ();
return std::conj (t);
}
static
BOOST_UBLAS_INLINE
real_type abs (const_reference t) {
return std::abs (t);
}
static
BOOST_UBLAS_INLINE
value_type sqrt (const_reference t) {
return std::sqrt (t);
}
static
BOOST_UBLAS_INLINE
real_type norm_1 (const_reference t) {
// Oops, should have known that!
return type_traits<real_type>::abs (self_type::real (t)) +
type_traits<real_type>::abs (self_type::imag (t));
}
static
BOOST_UBLAS_INLINE
real_type norm_2 (const_reference t) {
return self_type::abs (t);
}
static
BOOST_UBLAS_INLINE
real_type norm_inf (const_reference t) {
// Oops, should have known that!
return std::max (type_traits<real_type>::abs (self_type::real (t)),
type_traits<real_type>::abs (self_type::imag (t)));
}
static
BOOST_UBLAS_INLINE
bool equals (const_reference t1, const_reference t2) {
return self_type::norm_inf (t1 - t2) < BOOST_UBLAS_TYPE_CHECK_EPSILON *
std::max (std::max (self_type::norm_inf (t1),
self_type::norm_inf (t2)),
BOOST_UBLAS_TYPE_CHECK_MIN);
}
};
#endif
#ifdef BOOST_UBLAS_USE_INTERVAL
template<>
struct type_traits<boost::numeric::interval<float> > {
typedef type_traits<boost::numeric::interval<float> > self_type;
typedef boost::numeric::interval<float> value_type;
typedef const boost::numeric::interval<float> &const_reference;
typedef boost::numeric::interval<float> &reference;
typedef boost::numeric::interval<float> real_type;
typedef boost::numeric::interval<double> precision_type;
BOOST_STATIC_CONSTANT (std::size_t, plus_complexity = 1);
BOOST_STATIC_CONSTANT (std::size_t, multiplies_complexity = 1);
static
BOOST_UBLAS_INLINE
real_type real (const_reference t) {
return t;
}
static
BOOST_UBLAS_INLINE
real_type imag (const_reference t) {
return 0;
}
static
BOOST_UBLAS_INLINE
value_type conj (const_reference t) {
return t;
}
static
BOOST_UBLAS_INLINE
real_type abs (const_reference t) {
return boost::numeric::abs (t);
}
static
BOOST_UBLAS_INLINE
value_type sqrt (const_reference t) {
return boost::numeric::sqrt (t);
}
static
BOOST_UBLAS_INLINE
real_type norm_1 (const_reference t) {
return self_type::abs (t);
}
static
BOOST_UBLAS_INLINE
real_type norm_2 (const_reference t) {
return self_type::abs (t);
}
static
BOOST_UBLAS_INLINE
real_type norm_inf (const_reference t) {
return self_type::abs (t);
}
static
BOOST_UBLAS_INLINE
bool equals (const_reference t1, const_reference t2) {
return self_type::norm_inf (t1 - t2) < BOOST_UBLAS_TYPE_CHECK_EPSILON *
std::max (std::max (self_type::norm_inf (t1),
self_type::norm_inf (t2)),
BOOST_UBLAS_TYPE_CHECK_MIN);
}
};
template<>
struct type_traits<boost::numeric::interval<double> > {
typedef type_traits<boost::numeric::interval<double> > self_type;
typedef boost::numeric::interval<double> value_type;
typedef const boost::numeric::interval<double> &const_reference;
typedef boost::numeric::interval<double> &reference;
typedef boost::numeric::interval<double> real_type;
#ifndef BOOST_UBLAS_USE_LONG_DOUBLE
typedef boost::numeric::interval<double> precision_type;
#else
typedef boost::numeric::interval<boost::numeric::interval<long double> > precision_type;
#endif
BOOST_STATIC_CONSTANT (std::size_t, plus_complexity = 1);
BOOST_STATIC_CONSTANT (std::size_t, multiplies_complexity = 1);
static
BOOST_UBLAS_INLINE
real_type real (const_reference t) {
return t;
}
static
BOOST_UBLAS_INLINE
real_type imag (const_reference t) {
return 0;
}
static
BOOST_UBLAS_INLINE
value_type conj (const_reference t) {
return t;
}
static
BOOST_UBLAS_INLINE
real_type abs (const_reference t) {
return boost::numeric::abs (t);
}
static
BOOST_UBLAS_INLINE
value_type sqrt (const_reference t) {
return boost::numeric::sqrt (t);
}
static
BOOST_UBLAS_INLINE
real_type norm_1 (const_reference t) {
return self_type::abs (t);
}
static
BOOST_UBLAS_INLINE
real_type norm_2 (const_reference t) {
return self_type::abs (t);
}
static
BOOST_UBLAS_INLINE
real_type norm_inf (const_reference t) {
return self_type::abs (t);
}
static
BOOST_UBLAS_INLINE
bool equals (const_reference t1, const_reference t2) {
return self_type::norm_inf (t1 - t2) < BOOST_UBLAS_TYPE_CHECK_EPSILON *
std::max (std::max (self_type::norm_inf (t1),
self_type::norm_inf (t2)),
BOOST_UBLAS_TYPE_CHECK_MIN);
}
};
#ifdef BOOST_UBLAS_USE_LONG_DOUBLE
template<>
struct type_traits<boost::numeric::interval<long double> > {
typedef type_traits<boost::numeric::interval<long double> > self_type;
typedef boost::numeric::interval<long double> value_type;
typedef const boost::numeric::interval<long double> &const_reference;
typedef boost::numeric::interval<long double> &reference;
typedef boost::numeric::interval<long double> real_type;
typedef boost::numeric::interval<long double> precision_type;
BOOST_STATIC_CONSTANT (std::size_t, plus_complexity = 1);
BOOST_STATIC_CONSTANT (std::size_t, multiplies_complexity = 1);
static
BOOST_UBLAS_INLINE
real_type real (const_reference t) {
return t;
}
static
BOOST_UBLAS_INLINE
real_type imag (const_reference t) {
return 0;
}
static
BOOST_UBLAS_INLINE
value_type conj (const_reference t) {
return t;
}
static
BOOST_UBLAS_INLINE
real_type abs (const_reference t) {
return boost::numeric::abs (t);
}
static
BOOST_UBLAS_INLINE
value_type sqrt (const_reference t) {
return boost::numeric::sqrt (t);
}
static
BOOST_UBLAS_INLINE
real_type norm_1 (const_reference t) {
return self_type::abs (t);
}
static
BOOST_UBLAS_INLINE
real_type norm_2 (const_reference t) {
return self_type::abs (t);
}
static
BOOST_UBLAS_INLINE
real_type norm_inf (const_reference t) {
return self_type::abs (t);
}
static
BOOST_UBLAS_INLINE
bool equals (const_reference t1, const_reference t2) {
return self_type::norm_inf (t1 - t2) < BOOST_UBLAS_TYPE_CHECK_EPSILON *
std::max (std::max (self_type::norm_inf (t1),
self_type::norm_inf (t2)),
BOOST_UBLAS_TYPE_CHECK_MIN);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -