source: git/factory/cf_irred.cc @ f5d2647

spielwiese
Last change on this file since f5d2647 was 16f511, checked in by Oleksandr Motsak <motsak@…>, 11 years ago
Fixed the usage of "config.h" (if defined HAVE_CONFIG_H)
  • Property mode set to 100644
File size: 709 bytes
Line 
1/* emacs edit mode for this file is -*- C++ -*- */
2
3#ifdef HAVE_CONFIG_H
4#include "config.h"
5#endif /* HAVE_CONFIG_H */
6
7#include "cf_assert.h"
8
9#include "cf_defs.h"
10#include "canonicalform.h"
11#include "cf_algorithm.h"
12#include "cf_random.h"
13
14static bool
15is_irreducible ( const CanonicalForm & f )
16{
17    CFFList F = factorize( f );
18    return F.length() == 1 && F.getFirst().exp() == 1;
19}
20
21CanonicalForm
22find_irreducible ( int deg, CFRandom & gen, const Variable & x )
23{
24    CanonicalForm result;
25    int i;
26    do {
27        result = power( x, deg );
28        for ( i = deg-1; i >= 0; i-- )
29            result += gen.generate() * power( x, i );
30    } while ( ! is_irreducible( result ) );
31    return result;
32}
Note: See TracBrowser for help on using the repository browser.