source: git/factory/examples/gcd.cc @ 4e2385

spielwiese
Last change on this file since 4e2385 was 362fc67, checked in by Martin Lee <martinlee84@…>, 12 years ago
chg: remove $Id$
  • Property mode set to 100644
File size: 1.2 KB
Line 
1/* emacs edit mode for this file is -*- C++ -*- */
2
3//{{{ docu
4//
5// gcd.cc - sample Factory application.
6//
7//}}}
8
9#include <factory.h>
10
11int
12main()
13{
14    Variable x( 'x' );
15    Variable y( 'y' );
16    Variable z( 'z' );
17    CanonicalForm f;
18    CanonicalForm g;
19
20    cout << "Do not forget to terminate canonical forms with `;' in input!" << endl;
21
22    setCharacteristic( 0 );
23    On( SW_USE_EZGCD );
24    On( SW_RATIONAL );
25    cout << "Multivariate gcd calculation in characteristic 0." << endl;
26    cout << "Please enter two multivariate polynomials over Q." << endl;
27    cout << "f(x, y, z) = ";
28    cin >> f;
29    cout << "g(x, y, z) = ";
30    cin >> g;
31    cout << "f                  = " << f << endl;
32    cout << "g                  = " << g << endl;
33    cout << "gcd(f, g)          = " << gcd( f, g ) << endl << endl;
34
35    setCharacteristic( 29 );
36    cout << "Multivariate gcd calculation in GF(29)." << endl;
37    cout << "Please enter two multivariate polynomials over GF(29)." << endl;
38    cout << "f(x, y, z) = ";
39    cin >> f;
40    cout << "g(x, y, z) = ";
41    cin >> g;
42    cout << "f (mod 29)         = " << f << endl;
43    cout << "g (mod 29)         = " << g << endl;
44    cout << "gcd(f, g) (mod 29) = " << gcd( f, g ) << endl;
45}
Note: See TracBrowser for help on using the repository browser.