source: git/Singular/RingWrapper.cc @ f2dcd1

spielwiese
Last change on this file since f2dcd1 was f2dcd1, checked in by Frank Seelisch <seelisch@…>, 14 years ago
more stuff for C++ wrapper implementation git-svn-id: file:///usr/local/Singular/svn/trunk@12152 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 "ipshell.h"
6#include "grammar.h"
7#include "ipid.h"
8#include "polys.h"
9#include <iostream>
10#include "RingWrapper.h"
11#include "Wrappers.h"
12#include <stdio.h>
13#include <string.h>
14#include "febase.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..N */
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  assume(false); // the default constructor, i.e. the one
53                 // without arguments should never be called
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  {
69    strcat(str, "Q");
70  }
71  else
72  {
73    char h[10];
74    sprintf(h, "Z/%d", ch);
75    strcat(str, h);
76  }
77  strcat(str, "[");
78  for (int i = 0; i < n; i++) {
79    if (i > 0) strcat(str, ",");
80    strcat(str, m_singularRing->names[i]);
81  }
82  strcat(str, "], ordering = ");
83  if (m_singularRing->order[0] == ringorder_dp) strcat(str, "dp");
84  if (m_singularRing->order[0] == ringorder_lp) strcat(str, "lp");
85  if (m_singularRing->order[0] == ringorder_Dp) strcat(str, "Dp");
86  if (m_singularRing->order[0] == ringorder_ds) strcat(str, "ds");
87  if (m_singularRing->order[0] == ringorder_ls) strcat(str, "ls");
88  if (m_singularRing->order[0] == ringorder_Ds) strcat(str, "Ds");
89
90  return str;
91}
92
93void RingWrapper::print () const
94{
95  PrintS(this->toString());
96}
97
98void RingWrapper::printLn () const
99{
100  PrintS(this->toString());
101  PrintLn();
102}
103
104const SingularRing& RingWrapper::getSingularRing () const
105{
106  return m_singularRing;
107}
108
109bool RingWrapper::isCompatible (const RingWrapper& r) const
110{
111  bool result = (this == &r);
112  +prpr > "check for ring compatibility, result = " < (result ? "true" : "false");
113  return result;
114}
115
116#endif // HAVE_WRAPPERS
Note: See TracBrowser for help on using the repository browser.