source: git/Singular/CanonicalPoly.cc @ 2b78bd

spielwiese
Last change on this file since 2b78bd was 2b78bd, checked in by Frank Seelisch <seelisch@…>, 15 years ago
test code for Minors and C++Wrappers (with defines HAVE_MINOR and HAVE_WRAPPERS) git-svn-id: file:///usr/local/Singular/svn/trunk@12151 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 2.1 KB
Line 
1#include "mod2.h"
2
3#ifdef HAVE_WRAPPERS
4
5#include "structs.h"
6#include "polys.h"
7#include "CanonicalPoly.h"
8#include "Wrappers.h"
9#include <iostream>
10
11CanonicalPoly::CanonicalPoly (const SingularPoly& sp, const RingWrapper& r):InternPoly(r)
12{
13  +prpr > "CanonicalPoly constructor with poly argument = " <
14        p_String(sp, r.getSingularRing(), r.getSingularRing());
15  m_poly = sp;
16}
17
18CanonicalPoly::CanonicalPoly (const int i, const RingWrapper& r):InternPoly(r)
19{ // this method seems to work in char 0 only; is this due to a malfunction of p_ISet?
20  +prpr > "CanonicalPoly constructor with int argument = " < i;
21  m_poly = p_ISet(i, r.getSingularRing());
22}
23
24CanonicalPoly::~CanonicalPoly ()
25{
26  +prpr > "CanonicalPoly destructor, object = " < this->toString();
27  //p_Delete(&m_poly, m_ring.getSingularRing());
28}
29
30char* CanonicalPoly::toString () const
31{
32  SingularRing r = this->getRing().getSingularRing();
33  return p_String(this->getSingularPoly(), r, r);
34}
35
36void CanonicalPoly::addCompatible (const InternPoly* ip)
37{
38  if (ip->getPolyType() == 1)
39  {
40    const CanonicalPoly* pcp = static_cast<const CanonicalPoly*>(ip);
41    +prpr > "value of CanonicalPoly is being changed";
42    prpr+1;
43    +prpr > "old value = " < this->toString();
44    +prpr > "value to be added = " < pcp->toString();
45    m_poly = p_Add_q(m_poly, pcp->deepCopy()->getSingularPoly(), this->getRing().getSingularRing());
46    +prpr > "new value = " < this->toString();
47    prpr-1;
48    +prpr > "value of CanonicalPoly has been changed";
49  }
50  else
51  {
52    assume(false);
53  }
54}
55
56int CanonicalPoly::getPolyType () const
57{
58  return CANONICAL_POLY_TYPE;
59}
60
61const SingularPoly& CanonicalPoly::getSingularPoly () const
62{
63  return m_poly;
64}
65
66CanonicalPoly* CanonicalPoly::deepCopy () const
67{
68  +prpr > "creating a deep copy of CanonicalPoly, argument = " < this->toString();
69  SingularPoly sp = p_Copy(this->getSingularPoly(), this->getRing().getSingularRing());  // SINGULAR poly is deeply copied.
70  CanonicalPoly* pcp = new CanonicalPoly(sp, this->getRing());  // ring is not deeply copied!
71  return pcp;
72}
73
74#endif // HAVE_WRAPPERS
Note: See TracBrowser for help on using the repository browser.