x
Yes
No
Do you want to visit DriveHQ English website?
首页
产品服务
价格
免费试用
下载客户端
关于我们
云文件服务
|
云备份服务
|
FTP服务
|
企业邮箱服务
|
网站托管
|
客户端软件
云文件服务
云备份服务
FTP服务
企业级邮箱服务
网站托管
客户端软件
traits.hpp - Hosted on DriveHQ Cloud IT Platform
返回上层目录
上传
下载
共享
发布
新建文件夹
新建文件
复制
剪切
删除
粘贴
评论
升级服务
路径: \\game3dprogramming\materials\GameFactory\GameFactoryDemo\references\boost_1_35_0\boost\numeric\ublas\traits.hpp
旋转
特效
属性
历史版本
// // Copyright (c) 2000-2002 // Joerg Walter, Mathias Koch // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // The authors gratefully acknowledge the support of // GeNeSys mbH & Co. KG in producing this work. // #ifndef _BOOST_UBLAS_TRAITS_ #define _BOOST_UBLAS_TRAITS_ #include
#include
#include
#include
#include
#include
#include
#include
namespace boost { namespace numeric { namespace ublas { // Use Joel de Guzman's return type deduction // uBLAS assumes a common return type for all binary arithmetic operators template
struct promote_traits { typedef type_deduction_detail::base_result_of
base_type; static typename base_type::x_type x; static typename base_type::y_type y; static const std::size_t size = sizeof ( type_deduction_detail::test< typename base_type::x_type , typename base_type::y_type >(x + y) // Use x+y to stand of all the arithmetic actions ); static const std::size_t index = (size / sizeof (char)) - 1; typedef typename mpl::at_c< typename base_type::types, index>::type id; typedef typename id::type promote_type; }; // Type traits - generic numeric properties and functions template
struct type_traits; // Define properties for a generic scalar type template
struct scalar_traits { typedef scalar_traits
self_type; typedef T value_type; typedef const T &const_reference; typedef T &reference; typedef T real_type; typedef real_type precision_type; // we do not know what type has more precision then the real_type static const unsigned plus_complexity = 1; static const unsigned 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 type_abs (const_reference t) { // we'll find either std::abs or else another version via ADL: using namespace std; return abs (t); } static BOOST_UBLAS_INLINE value_type type_sqrt (const_reference t) { using namespace std; // force a type conversion back to value_type for intgral types // we'll find either std::sqrt or else another version via ADL: return value_type (sqrt (t)); } static BOOST_UBLAS_INLINE real_type norm_1 (const_reference t) { return self_type::type_abs (t); } static BOOST_UBLAS_INLINE real_type norm_2 (const_reference t) { return self_type::type_abs (t); } static BOOST_UBLAS_INLINE real_type norm_inf (const_reference t) { return self_type::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); } }; // Define default type traits, assume T is a scalar type template
struct type_traits : scalar_traits
{ typedef type_traits
self_type; typedef T value_type; typedef const T &const_reference; typedef T &reference; typedef T real_type; typedef real_type precision_type; static const unsigned multiplies_complexity = 1; }; // Define real type traits template<> struct type_traits
: scalar_traits
{ typedef type_traits
self_type; typedef float value_type; typedef const value_type &const_reference; typedef value_type &reference; typedef value_type real_type; typedef double precision_type; }; template<> struct type_traits
: scalar_traits
{ typedef type_traits
self_type; typedef double value_type; typedef const value_type &const_reference; typedef value_type &reference; typedef value_type real_type; typedef long double precision_type; }; template<> struct type_traits
: scalar_traits
{ typedef type_traits
self_type; typedef long double value_type; typedef const value_type &const_reference; typedef value_type &reference; typedef value_type real_type; typedef value_type precision_type; }; // Define properties for a generic complex type template
struct complex_traits { typedef complex_traits
self_type; typedef T value_type; typedef const T &const_reference; typedef T &reference; typedef typename T::value_type real_type; typedef real_type precision_type; // we do not know what type has more precision then the real_type static const unsigned plus_complexity = 2; static const unsigned multiplies_complexity = 6; static BOOST_UBLAS_INLINE real_type real (const_reference t) { return std::real (t); } static BOOST_UBLAS_INLINE real_type imag (const_reference t) { return std::imag (t); } static BOOST_UBLAS_INLINE value_type conj (const_reference t) { return std::conj (t); } static BOOST_UBLAS_INLINE real_type type_abs (const_reference t) { return abs (t); } static BOOST_UBLAS_INLINE value_type type_sqrt (const_reference t) { return sqrt (t); } static BOOST_UBLAS_INLINE real_type norm_1 (const_reference t) { return type_traits
::type_abs (self_type::real (t)) + type_traits
::type_abs (self_type::imag (t)); } static BOOST_UBLAS_INLINE real_type norm_2 (const_reference t) { return self_type::type_abs (t); } static BOOST_UBLAS_INLINE real_type norm_inf (const_reference t) { return (std::max) (type_traits
::type_abs (self_type::real (t)), type_traits
::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); } }; // Define complex type traits template<> struct type_traits
> : complex_traits
>{ typedef type_traits
> self_type; typedef std::complex
value_type; typedef const value_type &const_reference; typedef value_type &reference; typedef float real_type; typedef std::complex
precision_type; }; template<> struct type_traits
> : complex_traits
>{ typedef type_traits
> self_type; typedef std::complex
value_type; typedef const value_type &const_reference; typedef value_type &reference; typedef double real_type; typedef std::complex
precision_type; }; template<> struct type_traits
> : complex_traits
> { typedef type_traits
> self_type; typedef std::complex
value_type; typedef const value_type &const_reference; typedef value_type &reference; typedef long double real_type; typedef value_type precision_type; }; #ifdef BOOST_UBLAS_USE_INTERVAL // Define scalar interval type traits template<> struct type_traits
> : scalar_traits
> { typedef type_traits
> self_type; typedef boost::numeric::interval
value_type; typedef const value_type &const_reference; typedef value_type &reference; typedef value_type real_type; typedef boost::numeric::interval
precision_type; }; template<> struct type_traits
> : scalar_traits
> { typedef type_traits
> self_type; typedef boost::numeric::interval
value_type; typedef const value_type &const_reference; typedef value_type &reference; typedef value_type real_type; typedef boost::numeric::interval
precision_type; }; template<> struct type_traits
> : scalar_traits
> { typedef type_traits
> self_type; typedef boost::numeric::interval
value_type; typedef const value_type &const_reference; typedef value_type &reference; typedef value_type real_type; typedef value_type precision_type; }; #endif // Storage tags -- hierarchical definition of storage characteristics struct unknown_storage_tag {}; struct sparse_proxy_tag: public unknown_storage_tag {}; struct sparse_tag: public sparse_proxy_tag {}; struct packed_proxy_tag: public sparse_proxy_tag {}; struct packed_tag: public packed_proxy_tag {}; struct dense_proxy_tag: public packed_proxy_tag {}; struct dense_tag: public dense_proxy_tag {}; template
struct storage_restrict_traits { typedef S1 storage_category; }; template<> struct storage_restrict_traits
{ typedef sparse_proxy_tag storage_category; }; template<> struct storage_restrict_traits
{ typedef sparse_proxy_tag storage_category; }; template<> struct storage_restrict_traits
{ typedef sparse_proxy_tag storage_category; }; template<> struct storage_restrict_traits
{ typedef packed_proxy_tag storage_category; }; template<> struct storage_restrict_traits
{ typedef packed_proxy_tag storage_category; }; template<> struct storage_restrict_traits
{ typedef sparse_proxy_tag storage_category; }; template<> struct storage_restrict_traits
{ typedef sparse_proxy_tag storage_category; }; template<> struct storage_restrict_traits
{ typedef dense_proxy_tag storage_category; }; template<> struct storage_restrict_traits
{ typedef packed_proxy_tag storage_category; }; template<> struct storage_restrict_traits
{ typedef sparse_proxy_tag storage_category; }; template<> struct storage_restrict_traits
{ typedef packed_proxy_tag storage_category; }; template<> struct storage_restrict_traits
{ typedef sparse_proxy_tag storage_category; }; // Iterator tags -- hierarchical definition of storage characteristics struct sparse_bidirectional_iterator_tag : public std::bidirectional_iterator_tag {}; struct packed_random_access_iterator_tag : public std::random_access_iterator_tag {}; struct dense_random_access_iterator_tag : public packed_random_access_iterator_tag {}; // Thanks to Kresimir Fresl for convincing Comeau with iterator_base_traits ;-) template
struct iterator_base_traits {}; template<> struct iterator_base_traits
{ template
struct iterator_base { typedef forward_iterator_base
type; }; }; template<> struct iterator_base_traits
{ template
struct iterator_base { typedef bidirectional_iterator_base
type; }; }; template<> struct iterator_base_traits
{ template
struct iterator_base { typedef bidirectional_iterator_base
type; }; }; template<> struct iterator_base_traits
{ template
struct iterator_base { typedef random_access_iterator_base
type; }; }; template<> struct iterator_base_traits
{ template
struct iterator_base { typedef random_access_iterator_base
type; }; }; template<> struct iterator_base_traits
{ template
struct iterator_base { typedef random_access_iterator_base
type; }; }; template
struct iterator_restrict_traits { typedef I1 iterator_category; }; template<> struct iterator_restrict_traits
{ typedef sparse_bidirectional_iterator_tag iterator_category; }; template<> struct iterator_restrict_traits
{ typedef sparse_bidirectional_iterator_tag iterator_category; }; template<> struct iterator_restrict_traits
{ typedef sparse_bidirectional_iterator_tag iterator_category; }; template<> struct iterator_restrict_traits
{ typedef sparse_bidirectional_iterator_tag iterator_category; }; template<> struct iterator_restrict_traits
{ typedef packed_random_access_iterator_tag iterator_category; }; template<> struct iterator_restrict_traits
{ typedef packed_random_access_iterator_tag iterator_category; }; template
BOOST_UBLAS_INLINE void increment (I &it, const I &it_end, typename I::difference_type compare, packed_random_access_iterator_tag) { it += (std::min) (compare, it_end - it); } template
BOOST_UBLAS_INLINE void increment (I &it, const I &/* it_end */, typename I::difference_type /* compare */, sparse_bidirectional_iterator_tag) { ++ it; } template
BOOST_UBLAS_INLINE void increment (I &it, const I &it_end, typename I::difference_type compare) { increment (it, it_end, compare, typename I::iterator_category ()); } template
BOOST_UBLAS_INLINE void increment (I &it, const I &it_end) { #if BOOST_UBLAS_TYPE_CHECK I cit (it); while (cit != it_end) { BOOST_UBLAS_CHECK (*cit == typename I::value_type/*zero*/(), internal_logic ()); ++ cit; } #endif it = it_end; } namespace detail { // specialisation which define whether a type has a trivial constructor // or not. This is used by array types. template
struct has_trivial_constructor : public boost::has_trivial_constructor
{}; template
struct has_trivial_destructor : public boost::has_trivial_destructor
{}; template
struct has_trivial_constructor
> : public boost::true_type {}; template
struct has_trivial_destructor
> : public boost::true_type {}; } }}} #endif
traits.hpp
网页地址
文件地址
上一页
20/26
下一页
下载
( 17 KB )
Comments
Total ratings:
0
Average rating:
无评论
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.