-adic integers

1.Introduction

-adic numbers are implemented as a variant of the series over modular integers: the representation is the same, only the operations differ. All the necessary definitions are gathered in p_adic.hpp.

#include <numerix/p_adic.hpp>

#define C modular<modulus<int, modulus_int_preinverse<14> > >
#define V series_carry_variant_helper<C>::SV
#define P_adic series<C,V>

C::set_modulus (9973);
P_adic p (C (1), 1); // parameter p
P_adic f = 1 / (1 - p);
mmout << f[10] << "\n";

2.Specific variants

Naive algorithms for -adic numbers are implemented in series_carry_naive.hpp. The relaxed product is available from series_carry_relaxed.hpp.

3.Recursive -adic integers

The recursive power series framework extends to recursive -adic integers. In particular, the methods for solving regular linear systems or polynomial systems have been adapted to -adic integers and take into account the carries. See the documentation on Power series for more details.

4.Mathemagix interface

Mmx]  
p == modulus 7

:

Mmx]  
a == p_adic (1 mod p, 1 mod p)

:

Mmx]  
b == separable_root (a, 2)

:

Mmx]  
b^2

:

Mmx]  
p_expansion (100, p)

:

Mmx]  
p_adic (@p_expansion (100, p))

:

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License. If you don't have this file, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.