GMP(開源數學運算庫)

GMP,是GNU MP Bignum Library的縮寫,意思是開源數學運算庫。

基本介紹

  • 中文名:開源數學運算庫
  • 外文名:GNU MP Bignum Library
GMP是The GNU MP Bignum Library,是一個開源的數學運算庫,它可以用於任意精度的數學運算,包括有符號整數、有理數和浮點數。它本身並沒有精度限制,只取決於機器的硬體情況。
GMP is a free library for arbitrary precision arithmetic, operating on signed integers, rational numbers, and floating point numbers. There is no practical limit to the precision except the ones implied by the available memory in the machine GMP runs on. GMP has a rich set of functions, and the functions have a regular interface.
The main target applications for GMP are cryptography applications and research, Internet security applications, algebra systems, computational algebra research, etc.
GMP is carefully designed to be as fast as possible, both for small operands and for huge operands. The speed is achieved by using fullwords as the basic arithmetic type, by using fast algorithms, with highly optimized assembly code for the most common inner loops for a lot of CPUs, and by a general emphasis on speed.
GMP is faster than any other bignum library. The advantage for GMP increases with the operand sizes for many operations, since GMP uses asymptotically faster algorithms.
The first GMP release was made in 1991. It is continually developed and maintained, with a new release about once a year.
GMP is distributed under the GNU LGPL. This license makes the library free to use, share, and improve, and allows you to pass on the result. The license gives freedoms, but also sets firm restrictions on the use with non-free programs.
GMP is part of the GNU project. For more information about the GNU project, please see the official GNU web site.
GMP is brought to you by a team listed in the manual.
用法舉例:(GMP在PHP中的用法,用GMP庫計算階乘)
<?php
function fact($x)
{
$return = 1;
for ($i=2; $i < $x; $i++) {
$return = gmp_mul($return, $i);
}
return $return;
}
echo wordwrap(gmp_strval(fact(1000)), 75, "\n", true) . "\n"; // 為了排版方便,我們採用了斷行
?>。

相關詞條

熱門詞條

聯絡我們