On Oct 23, 2007, at 9:43 PM, Robert Bradshaw wrote:

>> 1) mpz_sizeinbase(..., 2) gives the number of bits in the number.
>> This will be O(1), but has to count how many bits are used in the
>> highest-order word.  mpz_sizeinbase(..., 16) or mpz_sizeinbase(...,
>> 32) may or may not be faster.
>>
>> 2) mpz_size(...) counts the number of words, but then you may have to
>> care about the difference between 32-bit and 64-bit machines.
>> (However, I could imagine that in this case just counting the size in
>> words is the right thing... maybe the cutoff should be twice as many
>> bits on a 64-bit processor.)
>
> Yes, both of these are functions. It would be nice to at least get
> the number of limbs via a macro (without using undocumented API or
> accessing the internals of the mpz_t struct directly (I know how to
> do that)).

In GMP 4.2.1, this is what appears in gmp.h:

#define mpz_size __gmpz_size
#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_size)
__GMP_DECLSPEC size_t mpz_size __GMP_PROTO ((mpz_srcptr))  
__GMP_NOTHROW __GMP_ATTRIBUTE_PURE;
#endif

and then later on,

#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_size)
#if ! defined (__GMP_FORCE_mpz_size)
__GMP_EXTERN_INLINE
#endif
size_t
mpz_size (mpz_srcptr __gmp_z) __GMP_NOTHROW
{
   return __GMP_ABS (__gmp_z->_mp_size);
}
#endif

It looks like they're trying pretty hard to make it inline.

david


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/
-~----------~----~----~----~------~----~------~--~---

Reply via email to