[97ff24] | 1 | /* emacs edit mode for this file is -*- C++ -*- */ |
---|
| 2 | |
---|
| 3 | //{{{ docu |
---|
| 4 | // |
---|
| 5 | // application.cc - sample Factory application. |
---|
| 6 | // |
---|
| 7 | //}}} |
---|
| 8 | |
---|
| 9 | #include <factory.h> |
---|
[c48e80] | 10 | #include <iostream.h> |
---|
[97ff24] | 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 | |
---|
[2a4c62] | 21 | cout << "Do not forget to terminate canonical forms with `;' in input!" << endl; |
---|
[c6e112] | 22 | |
---|
| 23 | // set our ring |
---|
| 24 | setCharacteristic( 0 ); |
---|
| 25 | On( SW_RATIONAL ); |
---|
| 26 | |
---|
[2a4c62] | 27 | cout << "Simple polynomial operations in characteristic 0." << endl; |
---|
| 28 | cout << "Please enter two multivariate polynomials over Q." << endl; |
---|
[97ff24] | 29 | cout << "f(x, y, z) = "; |
---|
| 30 | cin >> f; |
---|
| 31 | cout << "g(x, y, z) = "; |
---|
| 32 | cin >> g; |
---|
[2a4c62] | 33 | cout << "f = " << f << endl; |
---|
| 34 | cout << "g = " << g << endl; |
---|
[97ff24] | 35 | |
---|
[c6e112] | 36 | // call some of Factory's functions and methods and print |
---|
| 37 | // their results |
---|
[2a4c62] | 38 | cout << "Polynomial information on f:" << endl; |
---|
[97ff24] | 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 | |
---|
[2a4c62] | 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; |
---|
[97ff24] | 55 | } |
---|