⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rr.txt

📁 NTL is a high-performance, portable C++ library providing data structures and algorithms for manipul
💻 TXT
📖 第 1 页 / 共 2 页
字号:

// PROMOTIONS: operator / and procedure div promote double to RR on (a, b).



/**************************************************************************\

                       Transcendental functions 

\**************************************************************************/


void exp(RR& res, const RR& x);  // e^x
RR exp(const RR& x); 

void log(RR& res, const RR& x); // log(x) (natural log)
RR log(const RR& x); 

void log10(RR& res, const RR& x); // log(x)/log(10)
RR log10(const RR& x); 

void expm1(RR& res, const RR&  x);
RR expm1(const RR& x); 
// e^(x)-1; more accurate than exp(x)-1 when |x| is small

void log1p(RR& res, const RR& x);
RR log1p(const RR& x); 
// log(1 + x); more accurate than log(1 + x) when |x| is small

void pow(RR& res, const RR& x, const RR& y);  // x^y
RR pow(const RR& x, const RR& y); 

void sin(RR& res, const RR& x);  // sin(x); restriction: |x| < 2^1000
RR sin(const RR& x); 

void cos(RR& res, const RR& x);  // cos(x); restriction: |x| < 2^1000
RR cos(const RR& x); 

void ComputePi(RR& pi); // approximate pi to current precision
RR ComputePi_RR();


/**************************************************************************\

                         Rounding to integer values        

\**************************************************************************/


/*** RR output ***/

void trunc(RR& z, const RR& a);  // z = a, truncated to 0
RR trunc(const RR& a);

void floor(RR& z, const RR& a);  // z = a, truncated to -infinity
RR floor(const RR& a);

void ceil(RR& z, const RR& a);   // z = a, truncated to +infinity
RR ceil(const RR& a);

void round(RR& z, const RR& a);   // z = a, truncated to nearest integer
RR round(const RR& a);            // ties are rounded to an even integer



/*** ZZ output ***/

void TruncToZZ(ZZ& z, const RR& a);  // z = a, truncated to 0
ZZ TruncToZZ(const RR& a);

void FloorToZZ(ZZ& z, const RR& a);  // z = a, truncated to -infinity
ZZ FloorToZZ(const RR& a);           // same as RR to ZZ conversion

void CeilToZZ(ZZ& z, const RR& a);   // z = a, truncated to +infinity
ZZ CeilToZZ(const ZZ& a);

void RoundToZZ(ZZ& z, const RR& a);   // z = a, truncated to nearest integer
ZZ RoundToZZ(const RR& a);            // ties are rounded to an even integer


/**************************************************************************\

                                 Miscelaneous

\**************************************************************************/


void MakeRR(RR& z, const ZZ& a,  long e);
RR MakeRR(const ZZ& a,  long e);
// z = a*2^e, rounded to current precision

void random(RR& z);
RR random_RR(); 
// z = pseudo-random number in the range [0,1).
// Note that the behaviour of this function is somewhat platform
// dependent, because the underlying pseudo-ramdom generator is.


void SqrRoot(RR& z, const RR& a); // z = sqrt(a);
RR SqrRoot(const RR& a);
RR sqrt(const RR& a);

void power(RR& z, const RR& a, long e); // z = a^e, e may be negative
RR power(const RR& a, long e); 

void power2(RR& z, long e); // z = 2^e, e may be negative
RR power2_RR(long e); 


void clear(RR& z);  // z = 0
void set(RR& z);  // z = 1

void swap(RR& a, RR& b);  // swaps a and b (by swapping pointers)



/**************************************************************************\

                               Input/Output
Input Syntax:

<number>: [ "-" ] <unsigned-number>
<unsigned-number>: <dotted-number> [ <e-part> ] | <e-part>
<dotted-number>: <digits> | <digits> "." <digits> | "." <digits> | <digits> "."
<digits>: <digit> <digits> | <digit>
<digit>: "0" | ... | "9"
<e-part>: ( "E" | "e" ) [ "+" | "-" ] <digits>

Examples of valid input:

17 1.5 0.5 .5 5.  -.5  e10 e-10 e+10 1.5e10 .5e10 .5E10

Note that the number of decimal digits of precision that are used
for output can be set to any number p >= 1 by calling
the routine RR::SetOutputPrecision(p).  The default value of p is 10.
The current value of p is returned by a call to RR::OutputPrecision().


\**************************************************************************/



ostream& operator<<(ostream& s, const RR& a);
istream& operator>>(istream& s, RR& x);

/**************************************************************************\


            Specialized routines with explicit precision parameter

These routines take an explicit precision parameter p.  The value of p may be
any positive integer.  All results are computed to *precisely* p bits of
precision, regardless of the current precision (as set by RR::SetPrecision).

These routines are provided both for convenience and for situations where the
computation must be done with a precision that may be less than 53.


\**************************************************************************/




void AddPrec(RR& z, const RR& a, const RR& b, long p); // z = a + b
RR AddPrec(const RR& a, const RR& b, long p);

void SubPrec(RR& z, const RR& a, const RR& b, long p); // z = a - b
RR SubPrec(const RR& a, const RR& b, long p);

void NegatePrec(RR& z, const RR& a, long p); // z = -a
RR NegatePrec(const RR& a, long p);

void AbsPrec(RR& z, const RR& a, long p); // z = |a|
RR AbsPrec(const RR& a, long p);

void MulPrec(RR& z, const RR& a, const RR& b, long p); // z = a*b
RR MulPrec(const RR& a, const RR& b, long p);

void SqrPrec(RR& z, const RR& a, long p); // z = a*a
RR SqrPrec(const RR& a, long p);

void DivPrec(RR& z, const RR& a, const RR& b, long p);  // z = a/b
RR DivPrec(const RR& a, const RR& b, long p);

void InvPrec(RR& z, const RR& a, long p);  // z = 1/a
RR DivPrec(const RR& a, long p);

void SqrRootPrec(RR& z, const RR& a, long p); // z = sqrt(a)
RR SqrRootPrec(const RR& a, long p);

void TruncPrec(RR& z, const RR& a, long p); // z = a, truncated to 0
RR TruncPrec(const RR& a, long p);

void FloorPrec(RR& z, const RR& a, long p); // z = a, truncated to -infinity
RR FloorPrec(const RR& a, long p);

void CeilPrec(RR& z, const RR& a, long p);  // z = a, truncated to +infinity
RR CeilPrec(const RR& a, long p);

void RoundPrec(RR& z, const RR& a, long p); // z = a, 
                                            // truncated to nearest integer,
                                            // ties are roundec to an even 
                                            // integer
RR RoundPrec(const RR& a, long p);

void ConvPrec(RR& z, const RR& a, long p); // z = a
RR ConvPrec(const RR& a, long p);

void ConvPrec(RR& z, const ZZ& a, long p); // z = a
RR ConvPrec(const ZZ& a, long p);

void ConvPrec(RR& z, long a, long p); // z = a
RR ConvPrec(long a, long p);

void ConvPrec(RR& z, int a, long p); // z = a
RR ConvPrec(int a, long p);

void ConvPrec(RR& z, unsigned long a, long p); // z = a
RR ConvPrec(unsigned long a, long p);

void ConvPrec(RR& z, unsigned int a, long p); // z = a 
RR ConvPrec(unsigned int a, long p);

void ConvPrec(RR& z, double a, long p); // z = a
RR ConvPrec(double a, long p);

void ConvPrec(RR& z, const xdouble& a, long p); // z = a
RR ConvPrec(const xdouble& a, long p);

void ConvPrec(RR& z, const quad_float& a, long p); // z = a
RR ConvPrec(const quad_float& a, long p);

void ConvPrec(RR& z, const char *s, long p); // read z from s
RR ConvPrec(const char *s, long p);

void InputPrec(RR& z, istream& s, long p); // read z from s
RR InputPrec(istream& s, long p);

void MakeRRPrec(RR& z, const ZZ& a, long e, long p); // z = a*2^e
RR MakeRRPrec(const ZZ& a, long e, long p);


/**************************************************************************\

COMPATABILITY NOTES: 

 (1)  Prior to version 5.3, the documentation indicated that under certain
      circumstances, the value of the current precision could be directly set
      by setting the variable RR::prec.  Such usage is now considered
      obsolete.  To perform computations using a precision of less than 53
      bits, users should use the specialized routines AddPrec, SubPrec, etc.,
      documented above.

 (2)  The routine RoundToPrecision is obsolete, although for backward
      compatability, it is still declared (in both procedural and function
      forms), and is equivalent to ConvPrec.

 (3)  In versions 2.0 and earlier, the assignment operator and copy
      constructor for the class RR rounded their outputs to the current
      precision.  This is no longer the case:  their outputs are now exact
      copies of their inputs, regardless of the current precision.

\**************************************************************************/


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -