1 | /* emacs edit mode for this file is -*- C++ -*- */ |
---|
2 | /* $Id: application.cc,v 1.4 1998-03-13 17:03:49 schmidt Exp $ */ |
---|
3 | |
---|
4 | //{{{ docu |
---|
5 | // |
---|
6 | // application.cc - sample Factory application. |
---|
7 | // |
---|
8 | //}}} |
---|
9 | |
---|
10 | #include <factory.h> |
---|
11 | |
---|
12 | int |
---|
13 | main() |
---|
14 | { |
---|
15 | Variable x( 'x' ); |
---|
16 | Variable y( 'y' ); |
---|
17 | Variable z( 'z' ); |
---|
18 | CanonicalForm f; |
---|
19 | CanonicalForm g; |
---|
20 | |
---|
21 | cout << "Do not forget to terminate canonical forms with `;' in input!" << endl; |
---|
22 | |
---|
23 | // set our ring |
---|
24 | setCharacteristic( 0 ); |
---|
25 | On( SW_RATIONAL ); |
---|
26 | |
---|
27 | cout << "Simple polynomial operations in characteristic 0." << endl; |
---|
28 | cout << "Please enter two multivariate polynomials over Q." << endl; |
---|
29 | cout << "f(x, y, z) = "; |
---|
30 | cin >> f; |
---|
31 | cout << "g(x, y, z) = "; |
---|
32 | cin >> g; |
---|
33 | cout << "f = " << f << endl; |
---|
34 | cout << "g = " << g << endl; |
---|
35 | |
---|
36 | // call some of Factory's functions and methods and print |
---|
37 | // their results |
---|
38 | cout << "Polynomial information on f:" << endl; |
---|
39 | cout << "mvar(f) = " << mvar( f ) << endl; |
---|
40 | cout << "degree(f) = " << degree( f ) << endl; |
---|
41 | cout << "degree(f, x) = " << degree( f, x ) << endl; |
---|
42 | cout << "degree(f, y) = " << degree( f, y ) << endl; |
---|
43 | cout << "degree(f, z) = " << degree( f, z ) << endl; |
---|
44 | cout << "LC(f, x) = " << LC( f, x ) << endl; |
---|
45 | cout << "LC(f, y) = " << LC( f, y ) << endl; |
---|
46 | cout << "LC(f, z) = " << LC( f, z ) << endl; |
---|
47 | |
---|
48 | cout << "Arithmetic operators:" << endl; |
---|
49 | cout << "f+g = " << f + g << endl; |
---|
50 | cout << "f-g = " << f - g << endl; |
---|
51 | cout << "f*g = " << f * g << endl; |
---|
52 | cout << "f/g = " << f / g << endl; |
---|
53 | cout << "f%g = " << f % g << endl; |
---|
54 | cout << "f(g, x) = " << f(g, x) << endl; |
---|
55 | } |
---|