source: git/factory/cf_irred.cc @ 806c18

spielwiese
Last change on this file since 806c18 was 806c18, checked in by Hans Schoenemann <hannes@…>, 13 years ago
format git-svn-id: file:///usr/local/Singular/svn/trunk@13655 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 669 bytes
Line 
1/* emacs edit mode for this file is -*- C++ -*- */
2/* $Id$ */
3
4#include <config.h>
5
6#include "assert.h"
7
8#include "cf_defs.h"
9#include "canonicalform.h"
10#include "cf_algorithm.h"
11#include "cf_random.h"
12
13static bool
14is_irreducible ( const CanonicalForm & f )
15{
16    CFFList F = factorize( f );
17    return F.length() == 1 && F.getFirst().exp() == 1;
18}
19
20CanonicalForm
21find_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.