找回密码
 注册
查看: 589|回复: 0

R语言 Rmpfr包 mpfr()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-9-27 19:02:18 | 显示全部楼层 |阅读模式
mpfr(Rmpfr)
mpfr()所属R语言包:Rmpfr

                                        Create "mpfr" Numbers (Objects)
                                         创建“MPFR”(对象)

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

Create multiple (i.e. typically high) precision numbers, to be used in arithmetic and mathematical computations with R.
创建多个(即通常高)精度数字,用在算术和数学计算与R.


用法----------Usage----------


mpfr(x, precBits, base = 10, rnd.mode = c("N","D","U","Z"))
Const(name = c("pi", "gamma", "catalan", "log2"), prec = 120L)



参数----------Arguments----------

参数:x
a numeric, bigz, bigq, or character vector or array.
一个numeric,bigz,bigq或character矢量或array。


参数:precBits, prec
a number, the maximal precision to be used, in bits; i.e. 53 corresponds to double precision. Must be at least 2.  If missing, getPrec(x) determines a default precision.
一个数字,可以使用的最大精度位,即53对应的双精度。必须至少有2个。如果missing,getPrec(x)确定默认的精度。


参数:base
(only when x is character) the base with respect to which x[i] represent numbers; base b must fulfill 2 <= b <= 36.
(仅当x是character)的基础就到x[i]代表数字;baseb必须履行2 <= b <= 36。


参数:rnd.mode
a 1-letter string specifying how rounding should happen at C-level conversion to MPFR, see details.
有1个字母的字符串,该字符串指定了舍入应该发生在C-电平转换MPFR,查看详细信息。


参数:name
a string specifying the mpfrlib - internal constant computation.  "gamma" is Euler's gamma , and "catalan" Catalan's constant.
一个字符串,指定mpfrlib  - 内部常量计算。 "gamma"是欧拉的伽玛和"catalan"加泰罗尼亚语的常数。


Details

详细信息----------Details----------

MPFR supports four rounding modes,
MPFR支持四种舍入模式,




GMP_RNDN: round to nearest (roundTiesToEven in
GMP_RNDN:四舍五入到最接近的(roundTiesToEven在




GMP_RNDZ: round toward zero (roundTowardZero in
GMP_RNDZ:圆形趋向于零(roundTowardZero在




GMP_RNDU: round toward plus infinity (&ldquo;Up&rdquo;,
GMP_RNDU:向正无穷大(“向上”轮,




GMP_RNDD: round toward minus infinity (&ldquo;Down&rdquo;,
GMP_RNDD:圆形(“向下”,向负无穷大

The "round to nearest" ("N") mode, the default here, works as in the IEEE 754 standard: in case the number to be rounded lies exactly in the middle of two representable numbers, it is rounded to the one with the least significant bit set to zero.  For example, the number 5/2, which is represented by (10.1) in binary, is rounded to (10.0)=2 with a precision of two bits, and not to (11.0)=3.  This rule avoids the "drift" phenomenon mentioned by Knuth in volume 2 of The Art of Computer Programming (Section 4.2.2).
“轮最近的”("N")模式下,默认情况下在这里,工作在IEEE 754标准:要舍入的数恰好位于中间的两个可表示数字,它是四舍五入至一个与最少的有效位设置为零。例如,5/2,其在二进制表示的(10.1),(10.0)= 2,用两个比特精度被四舍五入,而不是(11.0)= 3。该规则避免了Knuth在计算机程序设计艺术(第4.2.2节)第2卷中提到的“漂移”现象。


值----------Value----------

an object of (S4) class mpfr, mpfrMatrix, or mpfrArray which the user should just as a normal numeric vector or array.
对象(S4)类mpfr,mpfrMatrix,或mpfrArray用户应该只是作为一个正常的数字向量或数组。


(作者)----------Author(s)----------


Martin Maechler



参考文献----------References----------

GNU MPFR &ndash; The Multiple Precision Floating-Point Reliable Library; Edition 2.4.2, November 2009; see http://www.mpfr.org/mpfr-current/#doc or directly http://www.mpfr.org/mpfr-current/mpfr.pdf.

参见----------See Also----------

The class documentation mpfr contains more details.
类文档mpfr包含更多的细节。


实例----------Examples----------


mpfr(pi, 120) ## the double-precision pi "translated" to 120-bit precision[#双精度圆周率“翻译”,以120位精度]

pi. &lt;- Const("pi", prec = 260) # pi "computed" to correct 260-bit precision[圆周率“计算”纠正260位精度]
pi. # nicely prints 80 digits [260 * log10(2) ~= 78.3 ~ 80][很好地打印80位[260 * LOG10(2)“~= 78.3~80]]

Const("gamma",   128L) # 0.5772...[0.5772 ...]
Const("catalan", 128L) # 0.9159...[0.9159 ...]

x &lt;- mpfr(0:7, 100)/7 # a more precise version of  k/7, k=0,..,7[K / 7,k = 0时,..,7的一个更精确的版本]
x
1 / x

## character input :[#字符输入:]
mpfr("2.718281828459045235360287471352662497757") - exp(mpfr(1, 150))
## ~= -4 * 10^-40[#~= 4 * 10 ^ -40]

## with some 'base' choices :[#与一些“碱基”的选择:]
print(mpfr("111.1111", base=2)) * 2^4

mpfr("af21.01020300a0b0c", base=16)
##  68 bit prec.  44833.00393694653820642[排名第68位PREC。 44833.00393694653820642]

## --- Large integers from package 'gmp':[#---大包“GMP”的整数:]
Z <- as.bigz(7)^(1:200)
head(Z, 40)
## mfpr(Z) by default chooses the correct *maximal* default precision:[Z):#mfpr(默认情况下,选择正确的极大*默认精度:]
mZ. <- mpfr(Z)
## more efficiently chooses precision individually[#更有效地选择精度个别]
m.Z <- mpfr(Z, precBits = frexpZ(Z)$exp)
## the precBits chosen are large enough to keep full precision:[#precBits选择足够大,以保持完整精度:]
stopifnot(identical(cZ <- as.character(Z),
                    as(mZ.,"character")),
          identical(cZ, as(m.Z,"character")))

## look at different "rounding modes":[#看看不同的“舍入模式”:]
sapply(c("N", "D","U","Z"), function(RND)
       mpfr(c(-1,1)/5, 20, rnd.mode = RND), simplify=FALSE)

symnum(sapply(c("N", "D","U","Z"),
              function(RND) mpfr(0.2, prec = 5:15, rnd.mode = RND) < 0.2 ))

转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2024-11-24 08:27 , Processed in 0.025485 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表