From a735c768872f360a8f72ecb335c1a9c1ad08cfa7 Mon Sep 17 00:00:00 2001 From: Dave Barr Date: Sun, 8 Feb 2004 08:46:23 +0000 Subject: [PATCH] - Add GMP function examples, and fix a few problems. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@150741 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/gmp/functions/gmp-abs.xml | 25 ++++++++++++- reference/gmp/functions/gmp-add.xml | 21 ++++++++++- reference/gmp/functions/gmp-and.xml | 22 ++++++++++- reference/gmp/functions/gmp-clrbit.xml | 35 ++++++++++++++++-- reference/gmp/functions/gmp-cmp.xml | 28 ++++++++++++-- reference/gmp/functions/gmp-com.xml | 26 +++++++++++-- reference/gmp/functions/gmp-div-q.xml | 37 ++++++++++++++++++- reference/gmp/functions/gmp-div-r.xml | 21 ++++++++++- reference/gmp/functions/gmp-divexact.xml | 25 ++++++++++++- reference/gmp/functions/gmp-fact.xml | 25 ++++++++++++- reference/gmp/functions/gmp-gcd.xml | 21 ++++++++++- reference/gmp/functions/gmp-hamdist.xml | 30 ++++++++++++++- reference/gmp/functions/gmp-intval.xml | 29 ++++++++++++++- reference/gmp/functions/gmp-invert.xml | 22 ++++++++++- reference/gmp/functions/gmp-jacobi.xml | 22 ++++++++++- reference/gmp/functions/gmp-legendre.xml | 22 ++++++++++- reference/gmp/functions/gmp-mod.xml | 21 ++++++++++- reference/gmp/functions/gmp-mul.xml | 21 ++++++++++- reference/gmp/functions/gmp-neg.xml | 24 +++++++++++- reference/gmp/functions/gmp-or.xml | 24 +++++++++++- .../gmp/functions/gmp-perfect-square.xml | 29 ++++++++++++++- reference/gmp/functions/gmp-popcount.xml | 24 +++++++++++- reference/gmp/functions/gmp-pow.xml | 26 ++++++++++++- reference/gmp/functions/gmp-powm.xml | 21 ++++++++++- reference/gmp/functions/gmp-prob-prime.xml | 29 ++++++++++++++- reference/gmp/functions/gmp-random.xml | 36 ++++++++++++++++-- reference/gmp/functions/gmp-scan0.xml | 29 ++++++++++++++- reference/gmp/functions/gmp-scan1.xml | 27 +++++++++++++- reference/gmp/functions/gmp-setbit.xml | 37 +++++++++++++++++-- reference/gmp/functions/gmp-sign.xml | 34 +++++++++++++++-- reference/gmp/functions/gmp-sqrt.xml | 33 +++++++++++++++-- reference/gmp/functions/gmp-sqrtrem.xml | 36 ++++++++++++++++-- reference/gmp/functions/gmp-sub.xml | 21 ++++++++++- reference/gmp/functions/gmp-xor.xml | 24 +++++++++++- 34 files changed, 855 insertions(+), 52 deletions(-) diff --git a/reference/gmp/functions/gmp-abs.xml b/reference/gmp/functions/gmp-abs.xml index 195fae3df2..ca8e6e3842 100644 --- a/reference/gmp/functions/gmp-abs.xml +++ b/reference/gmp/functions/gmp-abs.xml @@ -1,5 +1,5 @@ - + @@ -15,6 +15,29 @@ Returns absolute value of a. + + <function>gmp_abs</function> example + + +]]> + + + The printout of the above program will be: + + + + + diff --git a/reference/gmp/functions/gmp-add.xml b/reference/gmp/functions/gmp-add.xml index c9e6871f8e..afed97d74b 100644 --- a/reference/gmp/functions/gmp-add.xml +++ b/reference/gmp/functions/gmp-add.xml @@ -1,5 +1,5 @@ - + @@ -17,6 +17,25 @@ Add two GMP numbers. The result will be a GMP number representing the sum of the arguments. + + <function>gmp_add</function> example + + +]]> + + + The printout of the above program will be: + + + + + diff --git a/reference/gmp/functions/gmp-and.xml b/reference/gmp/functions/gmp-and.xml index 211932a5a8..06c57071eb 100644 --- a/reference/gmp/functions/gmp-and.xml +++ b/reference/gmp/functions/gmp-and.xml @@ -1,5 +1,5 @@ - + @@ -16,6 +16,26 @@ Calculates logical AND of two GMP numbers. + + <function>gmp_and</function> example + + + + + The printout of the above program will be: + + + + + diff --git a/reference/gmp/functions/gmp-clrbit.xml b/reference/gmp/functions/gmp-clrbit.xml index d08fae3cb7..d8f2da0b01 100644 --- a/reference/gmp/functions/gmp-clrbit.xml +++ b/reference/gmp/functions/gmp-clrbit.xml @@ -1,5 +1,5 @@ - + @@ -9,13 +9,42 @@ Description - resourcegmp_clrbit + voidgmp_clrbit resource&a intindex Clears (sets to 0) bit index in - a. + a. The index starts at 0. + + + + Unlike most of the other GMP functions, gmp_clrbit + must be called with a GMP resource that already exists (using + gmp_init for example). One will not be + automatically created. + + + + <function>gmp_clrbit</function> example + + + + + The printout of the above program will be: + + + + + + + See also gmp_setbit. diff --git a/reference/gmp/functions/gmp-cmp.xml b/reference/gmp/functions/gmp-cmp.xml index dd928cd095..514aebd36e 100644 --- a/reference/gmp/functions/gmp-cmp.xml +++ b/reference/gmp/functions/gmp-cmp.xml @@ -1,5 +1,5 @@ - + @@ -14,10 +14,32 @@ resourceb - Returns a positive value if a > b, zero if - a = b and negative value if a < + Returns a positive value if a > b, zero if + a = b and a negative value if a < b. + + <function>gmp_cmp</function> example + + +]]> + + + The printout of the above program will be: + + + + + diff --git a/reference/gmp/functions/gmp-com.xml b/reference/gmp/functions/gmp-com.xml index 9e2ee8ef0e..ffcc3c6475 100644 --- a/reference/gmp/functions/gmp-com.xml +++ b/reference/gmp/functions/gmp-com.xml @@ -1,10 +1,10 @@ - + gmp_com - Calculates one's complement of a + Calculates one's complement Description @@ -13,8 +13,28 @@ resourcea - &warn.undocumented.func; + Returns the one's complement of a. + + <function>gmp_com</function> example + + +]]> + + + The printout of the above program will be: + + + + + + diff --git a/reference/gmp/functions/gmp-div-q.xml b/reference/gmp/functions/gmp-div-q.xml index 112cd31296..d8963fa168 100644 --- a/reference/gmp/functions/gmp-div-q.xml +++ b/reference/gmp/functions/gmp-div-q.xml @@ -1,5 +1,5 @@ - + @@ -43,6 +43,41 @@ This function can also be called as gmp_div. + + <function>gmp_div_q</function> example + + +]]> + + + The printout of the above program will be: + + + + + See also gmp_div_r, gmp_div_qr diff --git a/reference/gmp/functions/gmp-div-r.xml b/reference/gmp/functions/gmp-div-r.xml index 038205008e..e8c65f25de 100644 --- a/reference/gmp/functions/gmp-div-r.xml +++ b/reference/gmp/functions/gmp-div-r.xml @@ -1,5 +1,5 @@ - + @@ -20,6 +20,25 @@ remainder has the sign of the n argument, if not zero. + + <function>gmp_div_r</function> example + + +]]> + + + The printout of the above program will be: + + + + + See the gmp_div_q function for description of the round argument. diff --git a/reference/gmp/functions/gmp-divexact.xml b/reference/gmp/functions/gmp-divexact.xml index 89c3ffff74..6f6c9d3cad 100644 --- a/reference/gmp/functions/gmp-divexact.xml +++ b/reference/gmp/functions/gmp-divexact.xml @@ -1,5 +1,5 @@ - + @@ -19,6 +19,29 @@ correct results only when it is known in advance that d divides n. + + <function>gmp_divexact</function> example + + +]]> + + + The printout of the above program will be: + + + + + diff --git a/reference/gmp/functions/gmp-fact.xml b/reference/gmp/functions/gmp-fact.xml index 884c5f854b..0caa106c7c 100644 --- a/reference/gmp/functions/gmp-fact.xml +++ b/reference/gmp/functions/gmp-fact.xml @@ -1,5 +1,5 @@ - + @@ -15,6 +15,29 @@ Calculates factorial (a!) of a. + + <function>gmp_fact</function> example + + +]]> + + + The printout of the above program will be: + + + + + diff --git a/reference/gmp/functions/gmp-gcd.xml b/reference/gmp/functions/gmp-gcd.xml index 542032fac6..addec9a55c 100644 --- a/reference/gmp/functions/gmp-gcd.xml +++ b/reference/gmp/functions/gmp-gcd.xml @@ -1,5 +1,5 @@ - + @@ -18,6 +18,25 @@ b. The result is always positive even if either of, or both, input operands are negative. + + <function>gmp_gcd</function> example + + +]]> + + + The printout of the above program will be: + + + + + diff --git a/reference/gmp/functions/gmp-hamdist.xml b/reference/gmp/functions/gmp-hamdist.xml index f887af6e28..e70a5d4758 100644 --- a/reference/gmp/functions/gmp-hamdist.xml +++ b/reference/gmp/functions/gmp-hamdist.xml @@ -1,5 +1,5 @@ - + @@ -17,6 +17,34 @@ Returns the hamming distance between a and b. Both operands should be non-negative. + + <function>gmp_hamdist</function> example + + +]]> + + + The printout of the above program will be: + + + + + + + See also gmp_popcount, + gmp_xor + diff --git a/reference/gmp/functions/gmp-intval.xml b/reference/gmp/functions/gmp-intval.xml index 53f7212264..9e3f65e96a 100644 --- a/reference/gmp/functions/gmp-intval.xml +++ b/reference/gmp/functions/gmp-intval.xml @@ -1,5 +1,5 @@ - + @@ -22,6 +22,33 @@ + + <function>gmp_intval</function> example + + +]]> + + + The printout of the above program will be: + + + + + diff --git a/reference/gmp/functions/gmp-invert.xml b/reference/gmp/functions/gmp-invert.xml index e0a8a4b748..935515d705 100644 --- a/reference/gmp/functions/gmp-invert.xml +++ b/reference/gmp/functions/gmp-invert.xml @@ -1,5 +1,5 @@ - + @@ -18,6 +18,26 @@ b. Returns &false; if an inverse does not exist. + + <function>gmp_invert</function> example + + +]]> + + + The printout of the above program will be: + + + + + diff --git a/reference/gmp/functions/gmp-jacobi.xml b/reference/gmp/functions/gmp-jacobi.xml index 7bf473c1cf..e944e0cf25 100644 --- a/reference/gmp/functions/gmp-jacobi.xml +++ b/reference/gmp/functions/gmp-jacobi.xml @@ -1,5 +1,5 @@ - + @@ -20,6 +20,26 @@ p. p should be odd and must be positive. + + <function>gmp_jacobi</function> example + + +]]> + + + The printout of the above program will be: + + + + + diff --git a/reference/gmp/functions/gmp-legendre.xml b/reference/gmp/functions/gmp-legendre.xml index 0e752e8fed..b98ab9a0a5 100644 --- a/reference/gmp/functions/gmp-legendre.xml +++ b/reference/gmp/functions/gmp-legendre.xml @@ -1,5 +1,5 @@ - + @@ -20,6 +20,26 @@ p. p should be odd and must be positive. + + <function>gmp_legendre</function> example + + +]]> + + + The printout of the above program will be: + + + + + diff --git a/reference/gmp/functions/gmp-mod.xml b/reference/gmp/functions/gmp-mod.xml index 9c96951955..d563e08cf7 100644 --- a/reference/gmp/functions/gmp-mod.xml +++ b/reference/gmp/functions/gmp-mod.xml @@ -1,5 +1,5 @@ - + @@ -18,6 +18,25 @@ d. The result is always non-negative, the sign of d is ignored. + + <function>gmp_mod</function> example + + +]]> + + + The printout of the above program will be: + + + + + diff --git a/reference/gmp/functions/gmp-mul.xml b/reference/gmp/functions/gmp-mul.xml index 9e24533a1d..e805258a2f 100644 --- a/reference/gmp/functions/gmp-mul.xml +++ b/reference/gmp/functions/gmp-mul.xml @@ -1,5 +1,5 @@ - + @@ -17,6 +17,25 @@ Multiplies a by b and returns the result. + + <function>gmp_mul</function> example + + +]]> + + + The printout of the above program will be: + + + + + diff --git a/reference/gmp/functions/gmp-neg.xml b/reference/gmp/functions/gmp-neg.xml index 83543f4eaa..1559287f7a 100644 --- a/reference/gmp/functions/gmp-neg.xml +++ b/reference/gmp/functions/gmp-neg.xml @@ -1,5 +1,5 @@ - + @@ -15,6 +15,28 @@ Returns -a. + + <function>gmp_neg</function> example + + +]]> + + + The printout of the above program will be: + + + + + diff --git a/reference/gmp/functions/gmp-or.xml b/reference/gmp/functions/gmp-or.xml index 42f8b6033e..58b8fc97ba 100644 --- a/reference/gmp/functions/gmp-or.xml +++ b/reference/gmp/functions/gmp-or.xml @@ -1,5 +1,5 @@ - + @@ -16,6 +16,28 @@ Calculates logical inclusive OR of two GMP numbers. + + <function>gmp_or</function> example + + +]]> + + + The printout of the above program will be: + + + + + diff --git a/reference/gmp/functions/gmp-perfect-square.xml b/reference/gmp/functions/gmp-perfect-square.xml index 03b239bec4..8badd59fed 100644 --- a/reference/gmp/functions/gmp-perfect-square.xml +++ b/reference/gmp/functions/gmp-perfect-square.xml @@ -1,5 +1,5 @@ - + @@ -16,6 +16,33 @@ Returns &true; if a is a perfect square, &false; otherwise. + + <function>gmp_perfect_square</function> example + + +]]> + + + The printout of the above program will be: + + + + + See also: gmp_sqrt, gmp_sqrtrm. diff --git a/reference/gmp/functions/gmp-popcount.xml b/reference/gmp/functions/gmp-popcount.xml index fcc82b9613..c05180cdb5 100644 --- a/reference/gmp/functions/gmp-popcount.xml +++ b/reference/gmp/functions/gmp-popcount.xml @@ -1,5 +1,5 @@ - + @@ -15,6 +15,28 @@ Return the population count of a. + + <function>gmp_popcount</function> example + + +]]> + + + The printout of the above program will be: + + + + + diff --git a/reference/gmp/functions/gmp-pow.xml b/reference/gmp/functions/gmp-pow.xml index 7c9f88525e..e120d498a4 100644 --- a/reference/gmp/functions/gmp-pow.xml +++ b/reference/gmp/functions/gmp-pow.xml @@ -1,5 +1,5 @@ - + @@ -18,6 +18,30 @@ exp. The case of 0^0 yields 1. exp cannot be negative. + + <function>gmp_pow</function> example + + +]]> + + + The printout of the above program will be: + + + + + diff --git a/reference/gmp/functions/gmp-powm.xml b/reference/gmp/functions/gmp-powm.xml index 83b96179a6..34d5972bc8 100644 --- a/reference/gmp/functions/gmp-powm.xml +++ b/reference/gmp/functions/gmp-powm.xml @@ -1,5 +1,5 @@ - + @@ -19,6 +19,25 @@ exp) modulo mod. If exp is negative, result is undefined. + + <function>gmp_powm</function> example + + +]]> + + + The printout of the above program will be: + + + + + diff --git a/reference/gmp/functions/gmp-prob-prime.xml b/reference/gmp/functions/gmp-prob-prime.xml index 9b5cd53992..2bc65a66c4 100644 --- a/reference/gmp/functions/gmp-prob-prime.xml +++ b/reference/gmp/functions/gmp-prob-prime.xml @@ -1,5 +1,5 @@ - + @@ -25,6 +25,33 @@ The function uses Miller-Rabin's probabilistic test. + + <function>gmp_prob_prime</function> example + + +]]> + + + The printout of the above program will be: + + + + + diff --git a/reference/gmp/functions/gmp-random.xml b/reference/gmp/functions/gmp-random.xml index 1c3f57a895..a6ba81ec45 100644 --- a/reference/gmp/functions/gmp-random.xml +++ b/reference/gmp/functions/gmp-random.xml @@ -1,5 +1,5 @@ - + @@ -14,10 +14,38 @@ Generate a random number. The number will be between - limiter and zero in value. If - limiter is negative, negative numbers are - generated. + zero and the number of bits per limb multiplied by + limiter. If limiter + is negative, negative numbers are generated. + + A limb is an internal GMP mechanism. The number of bits in a limb is + not static, and can vary from system to system. Generally, the number + of bits in a limb is either 16 or 32, but this is not guaranteed. + + + <function>gmp_random</function> example + + +]]> + + + The printout of the above program might be: + + + + + diff --git a/reference/gmp/functions/gmp-scan0.xml b/reference/gmp/functions/gmp-scan0.xml index 69f5dd2bc2..ff8509c7b6 100644 --- a/reference/gmp/functions/gmp-scan0.xml +++ b/reference/gmp/functions/gmp-scan0.xml @@ -1,5 +1,5 @@ - + @@ -17,8 +17,33 @@ Scans a, starting with bit start, towards more significant bits, until the first clear bit is found. Returns the index of the - found bit. + found bit. The index starts from 0. + + <function>gmp_scan0</function> example + + +]]> + + + The printout of the above program will be: + + + + + diff --git a/reference/gmp/functions/gmp-scan1.xml b/reference/gmp/functions/gmp-scan1.xml index 13540f88a2..c35385946a 100644 --- a/reference/gmp/functions/gmp-scan1.xml +++ b/reference/gmp/functions/gmp-scan1.xml @@ -1,5 +1,5 @@ - + @@ -19,6 +19,31 @@ until the first set bit is found. Returns the index of the found bit. + + <function>gmp_scan1</function> example + + +]]> + + + The printout of the above program will be: + + + + + diff --git a/reference/gmp/functions/gmp-setbit.xml b/reference/gmp/functions/gmp-setbit.xml index e43dc01cdd..1617201a33 100644 --- a/reference/gmp/functions/gmp-setbit.xml +++ b/reference/gmp/functions/gmp-setbit.xml @@ -1,5 +1,5 @@ - + @@ -9,7 +9,7 @@ Description - resourcegmp_setbit + voidgmp_setbit resource&a intindex boolset_clear @@ -18,7 +18,38 @@ Sets bit index in a. set_clear defines if the bit is set to 0 or 1. By default the bit is set to - 1. + 1. Index + + + + Unlike most of the other GMP functions, gmp_setbit + must be called with a GMP resource that already exists (using + gmp_init for example). One will not be + automatically created. + + + + <function>gmp_setbit</function> example + + +]]> + + + The printout of the above program will be: + + + + + + + See also gmp_clrbit. diff --git a/reference/gmp/functions/gmp-sign.xml b/reference/gmp/functions/gmp-sign.xml index 161cc77d09..8857b8c2b2 100644 --- a/reference/gmp/functions/gmp-sign.xml +++ b/reference/gmp/functions/gmp-sign.xml @@ -1,5 +1,5 @@ - + @@ -13,9 +13,37 @@ resourcea - Return sign of a - 1 if - a is positive and -1 if it's negative. + Returns 1 if a is positive, + -1 if a is negative, + and 0 if a is zero. + + <function>gmp_sign</function> example + + +]]> + + + The printout of the above program will be: + + + + + diff --git a/reference/gmp/functions/gmp-sqrt.xml b/reference/gmp/functions/gmp-sqrt.xml index 9c09e0e059..b108d283af 100644 --- a/reference/gmp/functions/gmp-sqrt.xml +++ b/reference/gmp/functions/gmp-sqrt.xml @@ -1,10 +1,10 @@ - + gmp_sqrt - Square root + Calculate square root Description @@ -13,8 +13,35 @@ resourcea - Calculates square root of a. + Calculates square root of a and returns the + integer portion of the result. + + <function>gmp_sqrt</function> example + + +]]> + + + The printout of the above program will be: + + + + + diff --git a/reference/gmp/functions/gmp-sqrtrem.xml b/reference/gmp/functions/gmp-sqrtrem.xml index c8338406ba..91f010369e 100644 --- a/reference/gmp/functions/gmp-sqrtrem.xml +++ b/reference/gmp/functions/gmp-sqrtrem.xml @@ -1,5 +1,5 @@ - + gmp_sqrtrem @@ -13,9 +13,39 @@ arraygmp_sqrtrem resourcea + + Returns array where first element is the integer square root of + a (see also + gmp_sqrt), and the second is the remainder + (i.e., the difference between a and the + first element squared). + + + <function>gmp_sqrtrem</function> example + + +]]> + + + The printout of the above program will be: + + + + + diff --git a/reference/gmp/functions/gmp-sub.xml b/reference/gmp/functions/gmp-sub.xml index fe7048cf01..6a7647423f 100644 --- a/reference/gmp/functions/gmp-sub.xml +++ b/reference/gmp/functions/gmp-sub.xml @@ -1,5 +1,5 @@ - + @@ -17,6 +17,25 @@ Subtracts b from a and returns the result. + + <function>gmp_sub</function> example + + +]]> + + + The printout of the above program will be: + + + + + diff --git a/reference/gmp/functions/gmp-xor.xml b/reference/gmp/functions/gmp-xor.xml index dd99cd17e7..272a379250 100644 --- a/reference/gmp/functions/gmp-xor.xml +++ b/reference/gmp/functions/gmp-xor.xml @@ -1,5 +1,5 @@ - + @@ -16,6 +16,28 @@ Calculates logical exclusive OR (XOR) of two GMP numbers. + + <function>gmp_xor</function> example + + +]]> + + + The printout of the above program will be: + + + + +