x
Yes
No
Do you want to visit DriveHQ English website?
首页
产品服务
价格
免费试用
下载客户端
关于我们
云文件服务
|
云备份服务
|
FTP服务
|
企业邮箱服务
|
网站托管
|
客户端软件
云文件服务
云备份服务
FTP服务
企业级邮箱服务
网站托管
客户端软件
simple_complex.hpp - Hosted on DriveHQ Cloud IT Platform
返回上层目录
上传
下载
共享
发布
新建文件夹
新建文件
复制
剪切
删除
粘贴
评论
升级服务
路径: \\game3dprogramming\materials\GameFactory\GameFactoryDemo\references\boost_1_35_0\boost\math\special_functions\detail\simple_complex.hpp
旋转
特效
属性
历史版本
// Copyright (c) 2007 John Maddock // Use, modification and distribution are subject to 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) #ifndef BOOST_MATH_SF_DETAIL_SIMPLE_COMPLEX_HPP #define BOOST_MATH_SF_DETAIL_SIMPLE_COMPLEX_HPP namespace boost{ namespace math{ namespace detail{ namespace sc{ template
class simple_complex { public: simple_complex() : r(0), i(0) {} simple_complex(T a) : r(a) {} template
simple_complex(U a) : r(a) {} simple_complex(T a, T b) : r(a), i(b) {} simple_complex& operator += (const simple_complex& o) { r += o.r; i += o.i; return *this; } simple_complex& operator -= (const simple_complex& o) { r -= o.r; i -= o.i; return *this; } simple_complex& operator *= (const simple_complex& o) { T lr = r * o.r - i * o.i; T li = i * o.r + r * o.i; r = lr; i = li; return *this; } simple_complex& operator /= (const simple_complex& o) { BOOST_MATH_STD_USING T lr; T li; if(fabs(o.r) > fabs(o.i)) { T rat = o.i / o.r; lr = r + i * rat; li = i - r * rat; rat = o.r + o.i * rat; lr /= rat; li /= rat; } else { T rat = o.r / o.i; lr = i + r * rat; li = i * rat - r; rat = o.r * rat + o.i; lr /= rat; li /= rat; } r = lr; i = li; return *this; } bool operator == (const simple_complex& o) { return (r == o.r) && (i == o.i); } bool operator != (const simple_complex& o) { return !((r == o.r) && (i == o.i)); } bool operator == (const T& o) { return (r == o) && (i == 0); } simple_complex& operator += (const T& o) { r += o; return *this; } simple_complex& operator -= (const T& o) { r -= o; return *this; } simple_complex& operator *= (const T& o) { r *= o; i *= o; return *this; } simple_complex& operator /= (const T& o) { r /= o; i /= o; return *this; } T real()const { return r; } T imag()const { return i; } private: T r, i; }; template
inline simple_complex
operator+(const simple_complex
& a, const simple_complex
& b) { simple_complex
result(a); result += b; return result; } template
inline simple_complex
operator-(const simple_complex
& a, const simple_complex
& b) { simple_complex
result(a); result -= b; return result; } template
inline simple_complex
operator*(const simple_complex
& a, const simple_complex
& b) { simple_complex
result(a); result *= b; return result; } template
inline simple_complex
operator/(const simple_complex
& a, const simple_complex
& b) { simple_complex
result(a); result /= b; return result; } template
inline T real(const simple_complex
& c) { return c.real(); } template
inline T imag(const simple_complex
& c) { return c.imag(); } template
inline T abs(const simple_complex
& c) { return hypot(c.real(), c.imag()); } }}}} // namespace #endif
simple_complex.hpp
网页地址
文件地址
上一页
22/24
下一页
下载
( 3 KB )
Comments
Total ratings:
0
Average rating:
无评论
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.