source: git/Singular/RingWrapper.cc @ 84d8bb3

spielwiese
Last change on this file since 84d8bb3 was 84d8bb3, checked in by Frank Seelisch <seelisch@…>, 14 years ago
change of print() using toString() git-svn-id: file:///usr/local/Singular/svn/trunk@12203 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 3.4 KB
Line 
1#include "mod2.h"
2
3#ifdef HAVE_WRAPPERS
4
5#include <iostream>
6#include <stdio.h>
7#include <string.h>
8#include "febase.h"
9#include "ipshell.h"
10#include "grammar.h"
11#include "ipid.h"
12#include "polys.h"
13#include "Wrappers.h"
14#include "RingWrapper.h"
15
16RingWrapper::RingWrapper (const char* ringName, const int characteristic,
17                          const int varNumber, const char** varNames, const char* ringOrder)
18{
19  +prpr > "creating a new RingWrapper (internal type: SINGULAR ring)";
20  m_singularRing = (ring) omAlloc0Bin(sip_sring_bin);
21  m_singularRing->ch    = characteristic;
22  m_singularRing->N     = varNumber;
23  m_singularRing->names = (char **) omAlloc0(varNumber * sizeof(char_ptr));
24  int i;
25  for (i = 0; i < varNumber; i++) m_singularRing->names[i]  = omStrDup(varNames[i]);
26  /* weights: entries for 2 blocks: NULL */
27  m_singularRing->wvhdl = (int **)omAlloc0(2 * sizeof(int_ptr));
28  /* order: ringOrder,0 */
29  m_singularRing->order  = (int *) omAlloc(2* sizeof(int *));
30  m_singularRing->block0 = (int *)omAlloc0(2 * sizeof(int *));
31  m_singularRing->block1 = (int *)omAlloc0(2 * sizeof(int *));
32  /* ringorder 'ringOrder' for the first block: var 1..varNumber */
33  if (strcmp(ringOrder, "dp") == 0) m_singularRing->order[0]  = ringorder_dp;
34  if (strcmp(ringOrder, "lp") == 0) m_singularRing->order[0]  = ringorder_lp;
35  if (strcmp(ringOrder, "Dp") == 0) m_singularRing->order[0]  = ringorder_Dp;
36  if (strcmp(ringOrder, "ds") == 0) m_singularRing->order[0]  = ringorder_ds;
37  if (strcmp(ringOrder, "ls") == 0) m_singularRing->order[0]  = ringorder_ls;
38  if (strcmp(ringOrder, "Ds") == 0) m_singularRing->order[0]  = ringorder_Ds;
39  m_singularRing->block0[0] = 1;
40  m_singularRing->block1[0] = varNumber;
41  /* the last block: everything is 0 */
42  m_singularRing->order[1]  = 0;
43  /* polynomial ring */
44  m_singularRing->OrdSgn    = 1;
45
46  /* complete ring intializations */
47  rComplete(m_singularRing);
48}
49
50RingWrapper::RingWrapper ()
51{
52  +prpr > "creating a new RingWrapper (internal type: SINGULAR ring)";
53  m_singularRing = currRing;
54}
55
56RingWrapper::~RingWrapper ()
57{
58  +prpr > "RingWrapper destructor, object = " < this->toString();
59}
60
61char* RingWrapper::toString () const
62{
63  char* str = new char[200];
64  strcpy(str, "");
65  int ch = rChar(m_singularRing);
66  int n = rVar(m_singularRing);
67  if (ch == 0)
68    strcat(str, "Q");
69  else
70  {
71    char h[10];
72    sprintf(h, "Z/%d", ch);
73    strcat(str, h);
74  }
75  strcat(str, "[");
76  for (int i = 0; i < n; i++)
77  {
78    if (i > 0) strcat(str, ",");
79    strcat(str, m_singularRing->names[i]);
80  }
81  strcat(str, "], ordering = ");
82  if (m_singularRing->order[0] == ringorder_dp) strcat(str, "dp");
83  if (m_singularRing->order[0] == ringorder_lp) strcat(str, "lp");
84  if (m_singularRing->order[0] == ringorder_Dp) strcat(str, "Dp");
85  if (m_singularRing->order[0] == ringorder_ds) strcat(str, "ds");
86  if (m_singularRing->order[0] == ringorder_ls) strcat(str, "ls");
87  if (m_singularRing->order[0] == ringorder_Ds) strcat(str, "Ds");
88
89  return str;
90}
91
92void RingWrapper::print () const
93{
94  char* s = this->toString();
95  PrintS(s);
96  delete s;
97}
98
99void RingWrapper::printLn () const
100{
101  char* s = this->toString();
102  PrintS(s);
103  PrintLn();
104  delete s;
105}
106
107const SingularRing& RingWrapper::getSingularRing () const
108{
109  return m_singularRing;
110}
111
112bool RingWrapper::isCompatible (const RingWrapper& r) const
113{
114  bool result = (this == &r);
115  +prpr > "check for ring compatibility, result = " < (result ? "true" : "false");
116  return result;
117}
118
119#endif
120/* HAVE_WRAPPERS */
Note: See TracBrowser for help on using the repository browser.