亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? tlargefloat.h

?? 利用數值分析方法
?? H
字號:
#ifndef _TLARGE_FLOAT_H__INCLUDED_
#define _TLARGE_FLOAT_H__INCLUDED_
 

#include <vector>
#include <sstream>
#include <string>
#include <Exception>
#include <limits>
#include <algorithm>

class TLargeFloat;//超高精度浮點數類TLargeFloat
class TLargeFloatException;//超高精度浮點數異常類

//改進方向:
//  1.強力優化ArrayMUL數組乘運算(當前算法復雜度為n*n),
//       可以使用二分算法來降低運算量,并使用復雜度為n*log(n)的快速復利葉變換或數論變換)
//  2.增加運算精度動態控制能力,有利于優化,減少乘法量;
//  3.添加新的基本運算函數,如:指數運算power、對數運算log、三角函數sin,cos,tan等
//  4.可以考慮:內部使用2的次方的底數;這樣的話,輸出函數就會麻煩一些了

//////注意:如果浮點數與TLargeFloat進行混合運算;
//  可能會產生誤差(有效位數會受到浮點數影響);
//  整數 或 為可表示整數的浮點數 參與運算不會產生誤差;


//超高精度浮點數異常類
class TLargeFloatException :public std::exception
{
private:
  std::string  m_ErrorMsg;
public:
 TLargeFloatException() {};
 TLargeFloatException(const char * Error_Msg)            :m_ErrorMsg(Error_Msg){ }
    virtual const char* what() const  throw()             {  return m_ErrorMsg.c_str();}
    virtual ~TLargeFloatException() throw() {}
};


//TCatchIntError只是對整數類型TInt進行的包裝
//設計TCatchIntError是為了當整數運算超出值域的時候,拋出異常
//超高精度浮點數類的指數運算時使用
template <typename TInt,typename TException,TInt MinValue,TInt MaxValue>
//<要包裝的整數類型,超界時拋出的異常類型,TInt最小值,TInt最大值>
class TCatchIntError
{
private:
 typedef TCatchIntError<TInt,TException,MinValue,MaxValue> SelfType;
 TInt  m_Int;
 SelfType& inc(TInt uValue)
 {
  if (MaxValue-uValue<m_Int) 
   throw TException("ERROR:TCatchIntError::inc(); ");
  m_Int+=uValue;
  return (*this);
 }
 SelfType& dec(TInt uValue)
 {
  if (MinValue+uValue>m_Int) 
   throw TException("ERROR:TCatchIntError::dec()");
  m_Int-=uValue;
  return (*this);
 }
public:
 TCatchIntError()        :m_Int(0){}
 TCatchIntError(TInt Value)      :m_Int(Value){}
 TCatchIntError(const SelfType& Value)   :m_Int(Value.m_Int){}
 TInt AsInt()const        { return m_Int; }
 SelfType& operator +=(TInt Value) //throw(TLargeFloatException)
             { if (Value<0) return dec(-Value);
              else return inc(Value); }
 SelfType& operator -=(TInt Value) //throw(TLargeFloatException)
             { if (Value<0)  return inc(-Value);
              else return dec(Value); }
 SelfType& operator +=(const SelfType& Value) { return (*this)+=(Value.m_Int); }//throw(TLargeFloatException)
 SelfType& operator -=(const SelfType& Value) { return (*this)-=(Value.m_Int); }//throw(TLargeFloatException)
};


  ////填寫編譯器支持的較大的整數類型
  //__int64 Int64_Min() { return std::numeric_limits<__int64>::min(); }//返回0, :(
  //__int64 Int64_Max() { return std::numeric_limits<__int64>::max(); }//返回0, :(
  //const __int64   Int64_Min = - __int64(9223372036854775808);//注意負號
  //const __int64   Int64_Max =   __int64(9223372036854775807);
  const long int   Int64_Min = -2147483648;//注意負號
  const long int   Int64_Max =  2147483647;

namespace Private_
{

template<typename T>
inline const T& min(const T& x,const T& y)//求最小值
{
    if (x>y)
        return y;
    else
        return x;
}

template<typename T>
inline const T& max(const T& x,const T& y)//求最大值
{
    if (x>y)
        return x;
    else
        return y;
}

template<typename T>
inline const T abs(const T& x)//求絕對值
{
    if (x<0)
        return -x;
    else
        return x;
}

template<typename T>
inline void swap(T& x,T& y) //交換兩個變量的值
{
    T temp=x;
    x=y;
    y=temp;
}

}//end namespace

//超高精度浮點數類
class TLargeFloat  
{
private:
 enum { 
  emLongDoubleDigits=std::numeric_limits<long double>::digits10,//long double的10進制有效精度
  emLongDoubleMaxExponent=std::numeric_limits<long double>::max_exponent10,//long double的最大10進制指數
  emLongDoubleMinExponent=std::numeric_limits<long double>::min_exponent10 };//long double的最小10進制指數
 typedef TLargeFloat     SelfType;
 typedef TLargeFloatException TException;
 typedef long int        Int32bit;//32bit位的整數類型,超過也可以
 //typedef __int64   TMaxInt; //填寫編譯器支持的較大的整數類型
 typedef long int   TMaxInt; //填寫編譯器支持的較大的整數類型
 
 typedef TCatchIntError<TMaxInt,TException,Int64_Min,Int64_Max> ExpInt;//注意:后面的兩個值為TMaxInt的最小值和最大值
 typedef std::vector<Int32bit> TArray;//小數位使用的數組類型
    enum { em10Power=4, emBase=10000};//數組為10000進制,數組的一個元素表示一位,對應4個十進制位
 
 Int32bit m_Sign;     //符號位  正:1,  負:-1, 零: 0
 ExpInt  m_Exponent; //保存10為底的指數
    TArray     m_Digits;  //小數部分 排列順序是TArray[0]為第一個小數位,依此類推;取值范圍0--999
  
    void Abs_Add(const SelfType& Value);//絕對值加  x:=|x|+|y|;
    void Abs_Sub_Abs(const SelfType& Value);//絕對值減的絕對值x:=| |x|-|y| |;
    void MoveLeft10Power(TMaxInt MoveCount);//十進制指數移動 值不變指數增大MoveCount
    void MoveRight10Power(TMaxInt MoveCount);//十進制指數移動 值不變指數減小MoveCount
 void MulInt(TMaxInt iValue);//乘以一個整數;
 void DivInt(TMaxInt iValue);//除以一個整數;
    void Clear();//清零
    void Chs();//求負

    int  Compare(const SelfType& Value) const;//比較兩個數;(*this)>Value 返回1,小于返回-1,相等返回0
    void Canonicity();//規格化 轉化值到合法格式
    static std::string  DigitToString(Int32bit iDigit);//將數組的一個元素轉換為字符串表示
 static void toEqExponent(SelfType& x,SelfType& y);//值不變,x,y的小數點對齊
    static void SetSameSizeMax(SelfType& x,SelfType& y);//使兩個高精度數的有效位數相同,位數小的進行提升
    static bool FloatIsInteger(long double fValue);//判斷浮點數是否為可表示整數
 static unsigned int DigitsSize(unsigned int uiDigitsLength);//

 //數組乘 (卷積result[i+j]=x[i]*y[j];)  //ArrayMUL 是需要優化的首要目標
 static void ArrayMUL(const Int32bit* x,const Int32bit* y,Int32bit* result,unsigned int MulSize);

 class TCharacter{};
 TLargeFloat(long double DefultFloatValue,const TCharacter&);//內部使用,浮點數轉化為 TLargeFloat
    void Abs();//絕對值
    void Rev();//求倒數1/x
    void RevSqrt();//求1/x^0.5;
    void Sqrt();//求x^0.5;

public:
 class TDigits//TDigits用來設置TLargeFloat的精度;//增加這個類是為了避免TLargeFloat的構造函數的可能誤用
 {
 private:
  unsigned int  m_eDigits;
 public:
  explicit TDigits(unsigned int uiDigitsLength)   :m_eDigits(uiDigitsLength){}
  unsigned int  GetDigits()const       { return m_eDigits; }
 };
 TLargeFloat(const SelfType& Value);
 TLargeFloat(long double DefultValue,const TDigits& DigitsLength);//TDigits (十進制的)有效位數
 virtual ~TLargeFloat(){}
    void swap(SelfType& Value);//交換值
 unsigned int GetDigitsLength() const;//返回當前的10進制有效位數
 void SetDigitsLength(unsigned int uiDigitsLength);//重新設置10進制有效位數
 void SetDigitsLength(const TDigits& DigitsLength)    { SetDigitsLength(DigitsLength.GetDigits()); }

    long double AsFloat() const;//轉化為浮點數
    std::string  AsString() const;//轉換為字符串

 const SelfType  operator -  () const;//求負   //注意:不能使用SelfType&
 const SelfType& operator +  () const;//求正   //注意:可以使用SelfType&,因為值不變

 SelfType& operator =  (long double   fValue); //注意:轉換可能存在小的誤差  
 SelfType& operator =  (const SelfType& Value); //編譯器默認的也行

 SelfType& operator *= (long double  fValue);
    SelfType& operator /= (long double  fValue);
 SelfType& operator += (long double  fValue);
 SelfType& operator -= (long double  fValue);

 SelfType& operator += (const SelfType& Value);
 SelfType& operator -= (const SelfType& Value);
 SelfType& operator *= (const SelfType& Value);
    SelfType& operator /= (const SelfType& Value);


 friend const TLargeFloat operator + (const TLargeFloat& x,const TLargeFloat& y);
 friend const TLargeFloat operator - (const TLargeFloat& x,const TLargeFloat& y);
 friend const TLargeFloat operator * (const TLargeFloat& x,const TLargeFloat& y);
 friend const TLargeFloat operator / (const TLargeFloat& x,const TLargeFloat& y);

 friend const TLargeFloat operator + (const TLargeFloat& x,long double y);
 friend const TLargeFloat operator - (const TLargeFloat& x,long double y);
 friend const TLargeFloat operator * (const TLargeFloat& x,long double y);
 friend const TLargeFloat operator / (const TLargeFloat& x,long double y);
 friend const TLargeFloat operator + (long double x,const TLargeFloat& y);
 friend const TLargeFloat operator - (long double x,const TLargeFloat& y);
 friend const TLargeFloat operator * (long double x,const TLargeFloat& y);
 friend const TLargeFloat operator / (long double x,const TLargeFloat& y);

 friend bool operator ==(const TLargeFloat& x,const TLargeFloat& y);
 friend bool operator < (const TLargeFloat& x,const TLargeFloat& y);
 friend bool operator ==(const TLargeFloat& x,long double y);
 friend bool operator < (const TLargeFloat& x,long double y);

 friend bool operator ==(long double x,const TLargeFloat& y) { return (y==x); }
 friend bool operator < (long double x,const TLargeFloat& y) { return (y>x); }

 friend bool operator !=(const TLargeFloat& x,const TLargeFloat& y) { return !(x==y); }
 friend bool operator > (const TLargeFloat& x,const TLargeFloat& y) { return (y<x); }
 friend bool operator >=(const TLargeFloat& x,const TLargeFloat& y) { return !(x<y); }
 friend bool operator <=(const TLargeFloat& x,const TLargeFloat& y) { return !(x>y); }

 friend bool operator !=(const TLargeFloat& x,long double y) { return !(x==y); }
 friend bool operator > (const TLargeFloat& x,long double y) { return (y<x); }
 friend bool operator >=(const TLargeFloat& x,long double y) { return !(x<y); }
 friend bool operator <=(const TLargeFloat& x,long double y) { return !(x>y); }

 friend bool operator !=(long double x,const TLargeFloat& y) { return !(x==y); }
 friend bool operator > (long double x,const TLargeFloat& y) { return (y<x); }
 friend bool operator >=(long double x,const TLargeFloat& y) { return !(x<y); }
 friend bool operator <=(long double x,const TLargeFloat& y) { return !(x>y); }

 friend std::ostream& operator << (std::ostream& cout, const TLargeFloat& Value) { return cout<<Value.AsString(); }
 friend void swap(TLargeFloat& x,TLargeFloat& y) { x.swap(y); } 

 friend const TLargeFloat abs(const TLargeFloat& x)  { TLargeFloat result(x); result.Abs(); return result; }//絕對值,|x|
 friend const TLargeFloat sqrt(const TLargeFloat& x) { TLargeFloat result(x); result.Sqrt(); return result;} //開方,x^0.5 
 friend const TLargeFloat revsqrt(const TLargeFloat& x) { TLargeFloat result(x); result.RevSqrt(); return result; }//求1/x^0.5;
 friend const TLargeFloat sqr(const TLargeFloat& x) { return x*x; };//平方,x^2
};

void LargeFloat_UnitTest();//正確性測試

void Debug_toCout(const std::string& strx,const TLargeFloat& x);//調試輸出

#endif // _TLARGE_FLOAT_H__INCLUDED_
// TLargeFloat.h
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色婷婷综合久久| 欧美精品1区2区3区| 日欧美一区二区| 国产日韩欧美电影| 欧美一区日本一区韩国一区| 成人丝袜高跟foot| 喷水一区二区三区| 亚洲日韩欧美一区二区在线| 久久久久久久久97黄色工厂| 91精品视频网| 欧美性色综合网| 成人教育av在线| 国产乱妇无码大片在线观看| 日韩精品一级二级| 亚洲一区二区视频| 国产精品你懂的在线欣赏| 欧美成人r级一区二区三区| 欧美午夜理伦三级在线观看| 成人sese在线| 久久精品72免费观看| 午夜激情综合网| 亚洲精选在线视频| 亚洲欧美电影一区二区| 国产日本欧美一区二区| 日韩精品一区二区在线| 欧美日韩精品三区| 欧美中文字幕不卡| 91小视频在线免费看| 粉嫩久久99精品久久久久久夜| 美腿丝袜亚洲综合| 免费高清在线一区| 日本不卡视频一二三区| 亚洲高清中文字幕| 一卡二卡三卡日韩欧美| 亚洲少妇30p| 亚洲欧美自拍偷拍| 亚洲日本免费电影| 亚洲色欲色欲www| 亚洲视频网在线直播| 亚洲人快播电影网| 中文字幕综合网| **欧美大码日韩| 最新欧美精品一区二区三区| 国产精品久线在线观看| 国产精品毛片久久久久久久| 欧美激情一区二区三区蜜桃视频| 国产欧美综合色| 国产精品拍天天在线| 国产精品传媒视频| 有坂深雪av一区二区精品| 亚洲精品国产精品乱码不99| 亚洲女爱视频在线| 亚洲一级在线观看| 日韩av一二三| 精彩视频一区二区| 成人毛片视频在线观看| 99国内精品久久| 在线观看视频一区| 欧美一区二区视频免费观看| 精品国产一区二区三区四区四| 久久综合色综合88| 国产精品三级在线观看| 亚洲人成在线观看一区二区| 樱花草国产18久久久久| 亚洲成人一区二区| 精品一区二区三区久久| 粉嫩嫩av羞羞动漫久久久| 色综合久久综合网欧美综合网| 欧美最新大片在线看| 欧美一区二区三区在线观看视频| 欧美电影免费提供在线观看| 国产清纯白嫩初高生在线观看91 | 色婷婷香蕉在线一区二区| 欧美色图在线观看| 日韩精品一区二区三区在线播放| 久久久久国产免费免费| 亚洲精品国产精品乱码不99| 麻豆国产91在线播放| 播五月开心婷婷综合| 欧美男生操女生| 国产欧美精品区一区二区三区| 亚洲婷婷在线视频| 久久99久久久欧美国产| 91麻豆.com| 欧美videossexotv100| 欧美韩日一区二区三区四区| 一区二区三区欧美在线观看| 蜜臀av一区二区| 91蝌蚪porny九色| 欧美成人综合网站| 伊人色综合久久天天| 激情成人综合网| 欧美午夜电影在线播放| 久久久久国色av免费看影院| 亚洲综合一区二区精品导航| 韩日欧美一区二区三区| 欧美日韩激情在线| 成人欧美一区二区三区在线播放| 麻豆精品一区二区综合av| 色妞www精品视频| www国产精品av| 亚洲18女电影在线观看| 99麻豆久久久国产精品免费优播| 制服丝袜亚洲精品中文字幕| 亚洲视频免费在线观看| 国产精品456| 91精选在线观看| 亚洲精品免费播放| 成人精品一区二区三区中文字幕| 日韩欧美一级在线播放| 性感美女久久精品| 色综合久久久久综合99| 中文一区一区三区高中清不卡| 日本欧美在线看| 在线观看日韩国产| 国产精品对白交换视频| 国产成人精品亚洲午夜麻豆| 精品日韩一区二区| 日本在线不卡视频一二三区| 在线区一区二视频| 亚洲婷婷综合久久一本伊一区| 国产精品一区二区三区乱码| 日韩视频免费观看高清完整版在线观看 | 成人黄色国产精品网站大全在线免费观看| 91精品在线观看入口| 亚洲成人在线观看视频| 日本精品一区二区三区四区的功能| 国产免费久久精品| 国产一区二区三区av电影| 日韩一区二区影院| 日本成人在线视频网站| 在线不卡欧美精品一区二区三区| 亚洲自拍偷拍麻豆| 色偷偷88欧美精品久久久| 自拍偷拍欧美激情| 日本高清成人免费播放| 综合网在线视频| 色综合久久久网| 尤物av一区二区| 欧美日韩三级一区| 视频一区在线播放| 欧美一区二区在线观看| 麻豆久久久久久久| 精品福利在线导航| 国产精品综合久久| 国产精品女上位| 91啪在线观看| 一区二区三区中文在线观看| 在线视频一区二区三| 亚洲高清中文字幕| 欧美一卡二卡三卡四卡| 精品在线一区二区三区| 精品91自产拍在线观看一区| 成人黄动漫网站免费app| 中文在线免费一区三区高中清不卡| 久久综合久色欧美综合狠狠| 免费在线看成人av| 97se狠狠狠综合亚洲狠狠| 久久久亚洲欧洲日产国码αv| 日韩一区二区三区高清免费看看| 欧美大度的电影原声| 亚洲欧美激情在线| 国产一区二区女| 日韩午夜激情av| 精品影院一区二区久久久| 91.com在线观看| 奇米影视一区二区三区| 欧美一卡二卡三卡四卡| 精品一区二区免费| 欧美精品高清视频| 亚洲视频免费观看| 欧美激情一区二区三区全黄| 最新不卡av在线| 成人一区在线看| 久久蜜桃一区二区| 亚洲精品免费一二三区| 亚洲一级二级在线| 成人av免费网站| 久久精品视频一区| 国产精品18久久久久久vr | 欧美一区二区三区免费在线看| 久久久久久影视| 日本成人在线看| 日韩一区二区三区三四区视频在线观看| 日韩一区二区三区四区五区六区| 欧美一区二区三区色| 亚洲欧美另类小说视频| 国产成人亚洲精品狼色在线| 精品久久久久av影院| 亚洲人成网站影音先锋播放| 国产一区二区影院| 精品视频在线视频| 亚洲va欧美va国产va天堂影院| 欧美三级视频在线| 免费成人在线影院| 99在线精品视频| 久久久亚洲欧洲日产国码αv| 国产成人午夜精品影院观看视频 | 欧美精品色一区二区三区| 亚洲激情第一区|