This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
g++: fix Digest::MD5, Math::BigInt::FastCalc, ODBM_File, XS::APItest (and Time::HiRes...
[perl5.git] / ext / Math / BigInt / FastCalc / FastCalc.pm
1 package Math::BigInt::FastCalc;
2
3 use 5.005;
4 use strict;
5 # use warnings; # dont use warnings for older Perls
6
7 use DynaLoader;
8 use Math::BigInt::Calc;
9
10 use vars qw/@ISA $VERSION $BASE $BASE_LEN/;
11
12 @ISA = qw(DynaLoader);
13
14 $VERSION = '0.10_01';
15
16 bootstrap Math::BigInt::FastCalc $VERSION;
17
18 ##############################################################################
19 # global constants, flags and accessory
20
21 # announce that we are compatible with MBI v1.70 and up
22 sub api_version () { 1; }
23  
24 BEGIN
25   {
26   # use Calc to override the methods that we do not provide in XS
27
28   for my $method (qw/
29     new str
30     add sub mul div
31     rsft lsft
32     mod modpow modinv
33     gcd
34     pow root sqrt log_int fac
35     digit check
36     from_hex from_bin as_hex as_bin
37     zeros length base_len
38     xor or and
39     /)
40     {
41     no strict 'refs';
42     *{'Math::BigInt::FastCalc::_' . $method} = \&{'Math::BigInt::Calc::_' . $method};
43     }
44   my ($AND_BITS, $XOR_BITS, $OR_BITS, $BASE_LEN_SMALL, $MAX_VAL);
45  
46   # store BASE_LEN and BASE to later pass it to XS code 
47   ($BASE_LEN, $AND_BITS, $XOR_BITS, $OR_BITS, $BASE_LEN_SMALL, $MAX_VAL, $BASE) =
48     Math::BigInt::Calc::_base_len();
49
50   }
51
52 sub import
53   {
54   _set_XS_BASE($BASE, $BASE_LEN);
55   }
56
57 ##############################################################################
58 ##############################################################################
59
60 1;
61 __END__
62
63 =head1 NAME
64
65 Math::BigInt::FastCalc - Math::BigInt::Calc with some XS for more speed
66
67 =head1 SYNOPSIS
68
69 Provides support for big integer calculations. Not intended to be used by
70 other modules. Other modules which sport the same functions can also be used
71 to support Math::BigInt, like L<Math::BigInt::GMP> or L<Math::BigInt::Pari>.
72
73 =head1 DESCRIPTION
74
75 In order to allow for multiple big integer libraries, Math::BigInt was
76 rewritten to use library modules for core math routines. Any module which
77 follows the same API as this can be used instead by using the following:
78
79         use Math::BigInt lib => 'libname';
80
81 'libname' is either the long name ('Math::BigInt::Pari'), or only the short
82 version like 'Pari'. To use this library:
83
84         use Math::BigInt lib => 'FastCalc';
85
86 Note that from L<Math::BigInt> v1.76 onwards, FastCalc will be loaded
87 automatically, if possible.
88
89 =head1 STORAGE
90
91 FastCalc works exactly like Calc, in stores the numbers in decimal form,
92 chopped into parts.
93
94 =head1 METHODS
95
96 The following functions are now implemented in FastCalc.xs:
97
98         _is_odd         _is_even        _is_one         _is_zero
99         _is_two         _is_ten
100         _zero           _one            _two            _ten
101         _acmp           _len            _num
102         _inc            _dec
103         __strip_zeros   _copy
104
105 =head1 LICENSE
106  
107 This program is free software; you may redistribute it and/or modify it under
108 the same terms as Perl itself. 
109
110 =head1 AUTHORS
111
112 Original math code by Mark Biggar, rewritten by Tels L<http://bloodgate.com/>
113 in late 2000.
114 Seperated from BigInt and shaped API with the help of John Peacock.
115 Fixed, sped-up and enhanced by Tels http://bloodgate.com 2001-2003.
116 Further streamlining (api_version 1 etc) by Tels 2004-2005.
117
118 =head1 SEE ALSO
119
120 L<Math::BigInt>, L<Math::BigFloat>, L<Math::BigInt::BitVect>,
121 L<Math::BigInt::GMP>, L<Math::BigInt::FastCalc> and L<Math::BigInt::Pari>.
122
123 =cut