Givaro
examples/FiniteField/exponentiation.C

NO DOC

// Copyright(c)'1994-2009 by The Givaro group
// This file is part of Givaro.
// Givaro is governed by the CeCILL-B license under French law
// and abiding by the rules of distribution of free software.
// see the COPYRIGHT file for more details.
#include <iostream>
#include <givaro/givpower.h>
#include <givaro/modular.h>
#include <givaro/gfq.h>
using namespace Givaro;
int main(int argc, char ** argv) {
{
Modular<int32_t> Z13(13); // modulo 13 over 32 bits
Z13.init(a, 7);
long l = 29;
dom_power(c, a, l, Z13); // c = 7^29 modulo 13 by squaring
std::cerr << "Within ";
Z13.write( std::cerr );
std::cerr << " : " << std::flush;
// Separate output writing
Z13.write( std::cout, a) << " ^ " << l << " = " << std::flush;
Z13.write( std::cerr, c) << std::endl;
}
{
int Mod = 13; int exponent = 1;
GFqDom<int> GF13( (TT) Mod, (TT) exponent ); // finite field with 13 elements
GF13.init(a, 7); // 7 modulo 13
long l = 29;
dom_power(c, a, l, GF13); // c = 7^29 modulo 13 by squaring
// Writing all outputs in a single command line
GF13.write( std::cerr << "Within " ) << " : " << std::flush;
GF13.write( GF13.write(
std::cout, a) << " ^ " << l << " = ", c) << std::endl;
}
return 0;
}
/* -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
// vim:sts=4:sw=4:ts=4:et:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s
int main(int argc, char **argv)
Definition: benchmark-recint_exp.C:20
Rep Element
Definition: gfq.h:79
UTT Residu_t
Definition: gfq.h:91
Storage_t Element
Definition: modular-inttype.h:49
Namespace in which the whole Givaro library resides.
Definition: all_field.C:23
TT & dom_power(TT &res, const TT &n, uint64_t l, const D &F)
dom_power
Definition: givpower.h:74
MG & a
Definition: rmadd.h:143
MG const rmint< K, MG > const T & c
Definition: rmadd.h:143