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