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