Givaro 4.2.1
examples/FiniteField/exponentiation.C

NO DOC.

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
class GFqDom
Definition gfq.h:44
Rep Element
Definition gfq.h:81
Rep & init(Rep &r) const
Definition gfq.h:204
UTT Residu_t
Definition gfq.h:93
std::ostream & write(std::ostream &s) const
Definition gfq.inl:606
std::ostream & write(std::ostream &s, const Element &a) const
Definition modular-implem.h:272
Forward declaration for Givaro::Modular.
Definition modular-inttype.h:38
Element & init(Element &x) const
Definition modular-inttype.h:61
Storage_t Element
Definition modular-inttype.h:49
int main()
Definition f4n3.cpp:22
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:76