source: git/Singular/Wrappers.cc @ a388ae

spielwiese
Last change on this file since a388ae was a388ae, checked in by Frank Seelisch <seelisch@…>, 14 years ago
added doxygen-like comments git-svn-id: file:///usr/local/Singular/svn/trunk@12198 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 3.5 KB
Line 
1#include "mod2.h"
2
3#ifdef HAVE_WRAPPERS
4
5#include <iostream>
6#include "febase.h"
7#include "Wrappers.h"
8#include "RingWrapper.h"
9#include "PolyWrapper.h"
10
11void test0 ();
12void test1 ();
13void test2 ();
14void test3 ();
15void test4 ();
16
17PrettyPrinter prpr("", "", false, false, -1, "   ");
18
19void wrapSINGULARPolys (const SingularPoly& sp1, const SingularPoly& sp2)
20{
21  prpr.setConsole(-1);
22  PrintLn();
23  RingWrapper r; /* wraps the current ring */
24  PolyWrapper p1(sp1, r);
25  PolyWrapper p2(sp2, r);
26  PrintS("This is how the created instances of PolyWrapper look like:");
27  PrintLn(); PrintS("p1 = "); p1.print();
28  PrintLn(); PrintS("p2 = "); p2.print();
29  PrintLn(); PrintS("And here comes their sum:");
30  PolyWrapper q = p1 + p2;
31  PrintLn(); PrintS("p1 + p2 = "); q.print();
32  PrintLn(); PrintLn();
33}
34
35void testWrappers (bool detailedOutput)
36{
37  prpr.setConsole(detailedOutput ? 0 : -1);
38  prpr+1;
39
40  test0();
41  test1();
42  test2();
43  test3();
44  test4();
45
46  prpr-1;
47  PrintLn();
48  PrintLn();
49}
50
51void test0 ()
52{
53  if (currRing != NULL)
54  {
55    PrintLn();
56    PrintS("Test0: Creation of RingWrapper from current SINGULAR ring");
57 
58    RingWrapper r;
59    PrintLn(); PrintS("r = "); r.print();
60  }
61}
62
63void test1 ()
64{
65  PrintLn();
66  PrintS("Test1: Creation and destruction of instances of RingWrapper");
67
68  const char* theVariables1[2] = {"x", "y"};
69  RingWrapper r1("myRing1", 7, 2, theVariables1, "dp");
70  PrintLn(); PrintS("r1 = "); r1.print();
71 
72  const char* theVariables2[3] = {"u", "v", "w"};
73  RingWrapper r2("myRing2", 0, 3, theVariables2, "Ds");
74  PrintLn(); PrintS("r2 = "); r2.print();
75}
76
77void test2 ()
78{
79  PrintLn();
80  PrintS("Test2: Creation, copying, assignment, and destruction of instances of PolyWrapper");
81 
82  const char* theVariables[2] = {"x", "y"};
83  RingWrapper r("myRing", 0, 2, theVariables, "lp");
84  PrintLn(); PrintS("r = "); r.print();
85 
86  PolyWrapper p1(4, r);
87  PrintLn(); PrintS("p1 = "); p1.print();
88  PolyWrapper p2(p1);
89  PrintLn(); PrintS("p2 = "); p2.print();
90  PolyWrapper p3(-37, r);
91  PrintLn(); PrintS("p3 = "); p3.print();
92  PolyWrapper p4(p3);
93  PrintLn(); PrintS("p4 = "); p4.print();
94  PolyWrapper p5 = p2;
95  PrintLn(); PrintS("p5 = "); p5.print();
96}
97
98void test3 ()
99{
100  PrintLn();
101  PrintS("Test3: Addition of compatible instances of PolyWrapper");
102 
103  const char* theVariables[2] = {"x", "y"};
104  RingWrapper r("myRing", 0, 2, theVariables, "Ds");
105  PrintLn(); PrintS("r = "); r.print();
106 
107  PolyWrapper p1(4, r);
108  PrintLn(); PrintS("p1 = "); p1.print();
109  PolyWrapper p2(7, r);
110  PrintLn(); PrintS("p2 = "); p2.print();
111  PolyWrapper p3 = p1 + p2;
112  PrintLn(); PrintS("p3 = "); p3.print();
113  p3 = p1;
114  PrintLn(); PrintS("p3 = "); p3.print();
115  p3 += p2;  /* this should change p3 but NOT p2! */
116  PrintLn(); PrintS("p3 = "); p3.print();
117  PrintLn(); PrintS("p2 = "); p2.print();
118}
119
120void test4 ()
121{
122  PrintLn();
123  PrintS("Test4: Addition of incompatible instances of PolyWrapper");
124 
125  const char* theVariables1[2] = {"x", "y"};
126  RingWrapper r1("myRing", 0, 2, theVariables1, "dp");
127  PrintLn(); PrintS("r1 = "); r1.print();
128
129  const char* theVariables2[2] = {"x", "z"};
130  RingWrapper r2("myRing", 0, 2, theVariables2, "dp");
131  PrintLn(); PrintS("r2 = "); r2.print();
132
133  PolyWrapper p1(4, r1);
134  PrintLn(); PrintS("p1 = "); p1.print();
135  PolyWrapper p2(7, r2);
136  PrintLn(); PrintS("p2 = "); p2.print();
137  PolyWrapper p3 = p1 + p2; /* this will not work */
138  /* The last instruction will abnormally stop the system call,
139     due to an "assume(false)". Use detailed output to see more
140     details. */
141}
142
143#endif
144/* HAVE_WRAPPERS */
Note: See TracBrowser for help on using the repository browser.