source: git/factory/cf_irred.cc @ 8797746

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