p-adic integers

1.Introduction

p-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 p-adic numbers are implemented in series_carry_naive.hpp. The relaxed product is available from series_carry_relaxed.hpp.

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.