[97ff24] | 1 | /* emacs edit mode for this file is -*- C++ -*- */ |
---|

[341696] | 2 | /* $Id$ */ |
---|

[97ff24] | 3 | |
---|

| 4 | //{{{ docu |
---|

| 5 | // |
---|

| 6 | // application.cc - sample Factory application. |
---|

| 7 | // |
---|

| 8 | //}}} |
---|

| 9 | |
---|

| 10 | #include <factory.h> |
---|

[c48e80] | 11 | #include <iostream.h> |
---|

[97ff24] | 12 | |
---|

| 13 | int |
---|

| 14 | main() |
---|

| 15 | { |
---|

| 16 | Variable x( 'x' ); |
---|

| 17 | Variable y( 'y' ); |
---|

| 18 | Variable z( 'z' ); |
---|

| 19 | CanonicalForm f; |
---|

| 20 | CanonicalForm g; |
---|

| 21 | |
---|

[2a4c62] | 22 | cout << "Do not forget to terminate canonical forms with `;' in input!" << endl; |
---|

[c6e112] | 23 | |
---|

| 24 | // set our ring |
---|

| 25 | setCharacteristic( 0 ); |
---|

| 26 | On( SW_RATIONAL ); |
---|

| 27 | |
---|

[2a4c62] | 28 | cout << "Simple polynomial operations in characteristic 0." << endl; |
---|

| 29 | cout << "Please enter two multivariate polynomials over Q." << endl; |
---|

[97ff24] | 30 | cout << "f(x, y, z) = "; |
---|

| 31 | cin >> f; |
---|

| 32 | cout << "g(x, y, z) = "; |
---|

| 33 | cin >> g; |
---|

[2a4c62] | 34 | cout << "f = " << f << endl; |
---|

| 35 | cout << "g = " << g << endl; |
---|

[97ff24] | 36 | |
---|

[c6e112] | 37 | // call some of Factory's functions and methods and print |
---|

| 38 | // their results |
---|

[2a4c62] | 39 | cout << "Polynomial information on f:" << endl; |
---|

[97ff24] | 40 | cout << "mvar(f) = " << mvar( f ) << endl; |
---|

| 41 | cout << "degree(f) = " << degree( f ) << endl; |
---|

| 42 | cout << "degree(f, x) = " << degree( f, x ) << endl; |
---|

| 43 | cout << "degree(f, y) = " << degree( f, y ) << endl; |
---|

| 44 | cout << "degree(f, z) = " << degree( f, z ) << endl; |
---|

| 45 | cout << "LC(f, x) = " << LC( f, x ) << endl; |
---|

| 46 | cout << "LC(f, y) = " << LC( f, y ) << endl; |
---|

| 47 | cout << "LC(f, z) = " << LC( f, z ) << endl; |
---|

| 48 | |
---|

[2a4c62] | 49 | cout << "Arithmetic operators:" << 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 = " << f % g << endl; |
---|

| 55 | cout << "f(g, x) = " << f(g, x) << endl; |
---|

[97ff24] | 56 | } |
---|