Changeset a388ae in git


Ignore:
Timestamp:
Oct 21, 2009, 5:36:00 PM (14 years ago)
Author:
Frank Seelisch <seelisch@…>
Branches:
(u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
Children:
9b4a332909ecddda93d19e235977388831620db1
Parents:
bb503c7363e3c90a3b0c5ae93374d5b7b20cc34a
Message:
added doxygen-like comments


git-svn-id: file:///usr/local/Singular/svn/trunk@12198 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
Singular
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • Singular/CanonicalPoly.cc

    rbb503c7 ra388ae  
    33#ifdef HAVE_WRAPPERS
    44
     5#include <iostream>
    56#include "structs.h"
    67#include "polys.h"
     8#include "Wrappers.h"
    79#include "CanonicalPoly.h"
    8 #include "Wrappers.h"
    9 #include <iostream>
    1010
    1111CanonicalPoly::CanonicalPoly (const SingularPoly& sp, const RingWrapper& r):InternPoly(r)
     
    1717
    1818CanonicalPoly::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?
     19{
    2020  +prpr > "CanonicalPoly constructor with int argument = " < i;
    2121  m_poly = p_ISet(i, r.getSingularRing());
     
    2525{
    2626  +prpr > "CanonicalPoly destructor, object = " < this->toString();
    27   //p_Delete(&m_poly, m_ring.getSingularRing());
    2827}
    2928
     
    3635void CanonicalPoly::addCompatible (const InternPoly* ip)
    3736{
    38   if (ip->getPolyType() == 1)
     37  if (ip->getPolyType() == CANONICAL_POLY_TYPE)
    3938  {
    4039    const CanonicalPoly* pcp = static_cast<const CanonicalPoly*>(ip);
     
    4948  }
    5049  else
    51   {
    5250    assume(false);
    53   }
    5451}
    5552
     
    6764{
    6865  +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!
     66  SingularPoly sp = p_Copy(this->getSingularPoly(), this->getRing().getSingularRing()); /* SINGULAR poly is deeply copied. */
     67  CanonicalPoly* pcp = new CanonicalPoly(sp, this->getRing()); /* ring is not deeply copied! */
    7168  return pcp;
    7269}
    7370
    74 #endif // HAVE_WRAPPERS
     71#endif
     72/* HAVE_WRAPPERS */
  • Singular/CanonicalPoly.h

    rbb503c7 ra388ae  
    55
    66#include "ring.h"
    7 #include "InternPoly.h"
    87#include <string>
    98#include "Wrappers.h"
     9#include "InternPoly.h"
    1010
    11 class CanonicalPoly : public InternPoly   // class for wrapping canonical SINGULAR polynomials
     11/*! \class CanonicalPoly
     12 *  \brief Class CanonicalPoly is the class for representing SINGULAR-internal,
     13 *         so-called canonical polynomials.
     14 *
     15 *  CanonicalPoly is derived from InternPoly which is derived from ReferenceCounter,
     16 *  thus any instance of CanonicalPoly deploys reference counting and
     17 *  facilities for fast shallow copying.<br>
     18 *  Any instance of CanonicalPoly wraps an actual SINGULAR polynomial.
     19 *  \author Frank Seelisch, http://www.mathematik.uni-kl.de/~seelisch
     20 */
     21class CanonicalPoly : public InternPoly
    1222{
    1323private:
     24  /*! placeholder for a SINGULAR-internal polynomial */
    1425  SingularPoly m_poly;
     26 
     27  /*!
     28   *  A method for retrieving the stored SINGULAR-internal polynomial.
     29   *  @return the stored SINGULAR-internal polynomial
     30   */
    1531  const SingularPoly& getSingularPoly () const;
     32protected:
     33  /*!
     34   *  A method for deeply copying the given instance of CanonicalPoly.<br>
     35   *  @return a pointer to the deep copy of <c>this</c> CanonicalPoly
     36   */
     37  CanonicalPoly* deepCopy () const;
     38 
     39  /*!
     40   *  A method for adding an instance of CanonicalPoly and an instance of
     41   *  InternPoly.<br>
     42   *  Both polynomials are known to live in compatible rings. For the time being,
     43   *  the implementation of this method will only succeed when the argument InternPoly
     44   *  can also be casted to CanonicalPoly. This cast will be performed static in case
     45   *  that <c>ip.getPolyType()</c> yields the enum CANONICAL_POLY_TYPE. Otherwise the
     46   *  program will halt.<br>
     47   *  In case of success, the result of the addition will be stored in the
     48   *  CanonicalPoly given by <c>*this</c>, hence the given object will then be modified
     49   *  by the operation.<br>
     50   *  @param ip another InternPoly to be added to <c>this</c> CanonicalPoly
     51   *  @see InternPoly::addCompatible (const InternPoly* ip)
     52   *  @see InternPoly::add (const InternPoly* ip)
     53   *  @see RingWrapper::isCompatible (const RingWrapper& r) const
     54   */
     55  void addCompatible (const InternPoly* ip);
     56 
     57  /*!
     58   *  A method for retrieving the type of the represented poly.
     59   *  For any class C derived from InternPoly, the call <c>C::getPolyType ()</c>
     60   *  is to return one of the defined enums so that, based on the return value, the
     61   *  programmer may perform a <em>static</em> cast to cast any given instance
     62   *  of InternPoly to the correct derived class.<br>
     63   *  This method needs to be reimplemented in each class derived from InternPoly.
     64   *  @return the enum CANONICAL_POLY_TYPE
     65   */
     66  int getPolyType () const;
     67 
     68  /*!
     69   *  A method for obtaining a string representation of the given instance.
     70   */
     71  char* toString () const;
    1672public:
    1773  ~CanonicalPoly ();
     74 
     75  /*!
     76   *  A constructor for CanonicalPoly.<br>
     77   *  This constructor will create a representation of the given integer
     78   *  as a wrapped SINGULAR-internal polynomial.
     79   *  @param r a RingWrapper wrapping the ring in which the polynomial lives
     80   *  @see CanonicalPoly::CanonicalPoly (const SingularPoly&, const RingWrapper& r)
     81   */
    1882  CanonicalPoly (const int i, const RingWrapper& r);
     83 
     84  /*!
     85   *  A constructor for CanonicalPoly.<br>
     86   *  This constructor will wrap the given SINGULAR-internal polynomial.
     87   *  @param r a RingWrapper wrapping the ring in which the polynomial lives
     88   *  @see CanonicalPoly::CanonicalPoly (const int i, const RingWrapper& r)
     89   */
    1990  CanonicalPoly (const SingularPoly&, const RingWrapper& r);
    20   void addCompatible (const InternPoly* ip);  // changes m_poly, i.e. given object
    21   CanonicalPoly* deepCopy () const;
    22   int getPolyType () const;
    23   char* toString () const;
     91 
     92/*! We enable PolyWrapper to "see" all methods of CanonicalPoly. */
     93friend class PolyWrapper;
    2494};
    2595
    26 #endif // HAVE_WRAPPERS
     96#endif
     97/* HAVE_WRAPPERS */
    2798
    2899#endif
  • Singular/InternPoly.cc

    rbb503c7 ra388ae  
    33#ifdef HAVE_WRAPPERS
    44
     5#include <iostream>
     6#include "Wrappers.h"
    57#include "InternPoly.h"
    6 #include "Wrappers.h"
    7 #include <iostream>
    88
    99InternPoly::InternPoly (const RingWrapper& r):m_ring(r)
     
    1515InternPoly::InternPoly (const InternPoly& ip):m_ring(ip.getRing())
    1616{
    17   assume(false); // shallow copy constructor should never be called
     17  assume(false); /* shallow copy constructor should never be called */
    1818}
    1919
    2020InternPoly* InternPoly::deepCopy () const
    2121{
    22   assume(false); // deep copy constructor should never be called
     22  assume(false); /* deep copy constructor should never be called */           
    2323}
    2424
    25 InternPoly::~InternPoly()
     25InternPoly::~InternPoly ()
    2626{
    2727  +prpr > "InternPoly destructor";
     
    3030char* InternPoly::toString () const
    3131{
    32   assume(false); // should be overridden by each derived class
     32  assume(false); /* should be overridden by each derived class */
    3333}
    3434
     
    4040void InternPoly::add (const InternPoly* ip) {
    4141  if (this->getRing().isCompatible(ip->getRing()))
    42   {
    4342    this->addCompatible(ip);
    44   }
    4543  else
    4644  {
     45    +prpr > "addition of objects in incompatible rings encountered";
    4746    assume(false);
    4847  }
     
    5655void InternPoly::addCompatible (const InternPoly* ip)
    5756{
    58   assume(false); // should be overridden by each derived class
     57  assume(false); /* should be overridden by each derived class */
    5958}
    6059
    61 #endif // HAVE_WRAPPERS
     60#endif
     61/* HAVE_WRAPPERS */
  • Singular/InternPoly.h

    rbb503c7 ra388ae  
    44#ifdef HAVE_WRAPPERS
    55
     6#include "Wrappers.h"
    67#include "ReferenceCounter.h"
    78#include "RingWrapper.h"
    89
     10/*! \class InternPoly
     11 *  \brief Class InternPoly is the superclass of all classes which
     12 *         wrap specific polynomial representations.
     13 *
     14 *  InternPoly is derived from ReferenceCounter, thus any instance of
     15 *  InternPoly and of its derived classes deploys reference counting and
     16 *  facilities for fast shallow copying.<br>
     17 *  Classes derived from InternPoly are intended to wrap specific polynomial
     18 *  representations such as SINGULAR-internal polynomials, as done by
     19 *  CanonicalPoly. Each such instance needs to <em>know</em> in which ring it
     20 *  lives. Therefore, InterPoly has a private member for storing a reference
     21 *  to some instance of RingWrapper.<br>
     22 *  Any instance of PolyWrapper holds a pointer to an instance of InternPoly
     23 *  wherein the polynomial is actually wrapped. This way, technicalities
     24 *  can be implemented inside InternPoly (and in the classes derived from it)
     25 *  and only the user interface for polynomail actions can by made available
     26 *  through PolyWrapper.<br>
     27 *  \author Frank Seelisch, http://www.mathematik.uni-kl.de/~seelisch
     28 */
    929class InternPoly : public ReferenceCounter
    1030{
    1131protected:
     32  /*! private member for storing a reference to a RingWrapper
     33      which wraps the ring in which the polynomial lives */
    1234  const RingWrapper& m_ring;
     35 
     36  /*! an enumeration variable for making the code more readable;
     37      for any class C derived from InternPoly, the call <c>C::getPolyType ()</c>
     38      is to return one of these enums so that, based on the return value, the
     39      programmer may perform a <em>static</em> cast to cast a given instance
     40      of InternPoly to the correct derived class */
     41  static const int UNSPECIFIED_POLY_TYPE = 0;
     42 
     43  /*! an enumeration variable for making the code more readable;
     44      for any class C derived from InternPoly, the call <c>C::getPolyType ()</c>
     45      is to return one of these enums so that, based on the return value, the
     46      programmer may perform a <em>static</em> cast to cast a given instance
     47      of InternPoly to the correct derived class */
     48  static const int CANONICAL_POLY_TYPE   = 1;
     49 
     50  /*!
     51   *  A method for retrieving the type of the represented poly.
     52   *  For any class C derived from InternPoly, the call <c>C::getPolyType ()</c>
     53   *  is to return one of the defined enums so that, based on the return value, the
     54   *  programmer may perform a <em>static</em> cast to cast any given instance
     55   *  of InternPoly to the correct derived class.<br>
     56   *  This method needs to be reimplemented in each class derived from InternPoly.
     57   *  @return the polynomial type, one of the defined enums
     58   */
     59  virtual int getPolyType () const;
     60 
     61  /*!
     62   *  A method for adding two instances of InterPoly which are known to
     63   *  live in the same, or at least in compatible rings.<br>
     64   *  The result of the addition will be stored in the InternPoly given by <c>*this</c>;
     65   *  hence the given object will be modified by the operation.<br>
     66   *  This method needs to be reimplemented in each class derived from InternPoly.
     67   *  @param ip another InternPoly to be added to <c>this</c> InternPoly
     68   *  @see InternPoly::add (const InternPoly* ip)
     69   *  @see RingWrapper::isCompatible (const RingWrapper& r) const
     70   */
     71  virtual void addCompatible (const InternPoly* ip);
     72 
     73  /*!
     74   *  A method for deeply copying the given instance of InternPoly.<br>
     75   *  This method needs to be reimplemented in each class derived from InternPoly.
     76   *  @return a pointer to the deep copy of <c>this</c> InternPoly
     77   */
     78  virtual InternPoly* deepCopy () const;
     79 
     80  /*!
     81   *  A method for retrieving the RingWrapper which wraps the ring in
     82   *  which the represented polynomial lives.<br>
     83   *  This method needs to be reimplemented in each class derived from InternPoly.
     84   *  @return a RingWrapper wrapping the ring in which the polynomial lives
     85   */
     86  const RingWrapper& getRing () const;
     87 
     88  /*!
     89   *  A method for adding two instances of InterPoly which are not known to
     90   *  live in compatible rings.<br>
     91   *  In case of compatibility, the result of the addition will be stored
     92   *  in the InternPoly given by <c>*this</c>, hence the given object will be
     93   *  modified by the operation.<br>
     94   *  @param ip another InternPoly to be added to <c>this</c> InternPoly
     95   *  @see InternPoly::addCompatible (const InternPoly* ip)
     96   *  @see RingWrapper::isCompatible (const RingWrapper& r) const
     97   */
     98  void add (const InternPoly* ip);
     99 
     100  /*!
     101   *  A method for obtaining a string representation of the given instance.<br>
     102   *  This method needs to be reimplemented in each class derived from InternPoly.
     103   */
     104  virtual char* toString () const;
    13105public:
     106  /*!
     107   *  A constructor for InternPoly which just sets the RingWrapper.<br>
     108   *  This constructor is assumed to be called implicitely when a constructor
     109   *  of one of the classes derived from InternPoly will be called.
     110   *  @param r a RingWrapper wrapping the ring in which the polynomial lives
     111   */
    14112  InternPoly (const RingWrapper& r);
     113 
     114  /*!
     115   *  A copy constructor for InternPoly.<br>
     116   *  As this constructor should neither be called by the user nor
     117   *  implicitely by some method, it will halt the program.
     118   *  @param p a reference to another InternPoly
     119   */
    15120  InternPoly (const InternPoly& p);
     121 
     122  /*!
     123   *  A destructor for InternPoly.
     124   */
    16125  virtual ~InternPoly ();
    17   const RingWrapper& getRing () const;
    18   void add (const InternPoly* ip);  // changes given object
    19   virtual void addCompatible (const InternPoly* ip);  // changes given object
    20   virtual InternPoly* deepCopy () const;
    21   virtual int getPolyType () const;
    22   virtual char* toString () const;
     126
     127/*! We enable PolyWrapper to "see" all methods of InternPoly. */
     128friend class PolyWrapper;
     129
     130/*! We enable CanonicalPoly to "see" all methods of InternPoly. */
     131friend class CanonicalPoly;
    23132};
    24133
    25 #endif // HAVE_WRAPPERS
     134#endif
     135/* HAVE_WRAPPERS */
    26136
    27137#endif
  • Singular/PolyWrapper.cc

    rbb503c7 ra388ae  
    33#ifdef HAVE_WRAPPERS
    44
    5 #include "PolyWrapper.h"
    6 #include "CanonicalPoly.h"
    7 #include "Wrappers.h"
    85#include <iostream>
    96#include "febase.h"
     7#include "Wrappers.h"
     8#include "PolyWrapper.h"
     9#include "RingWrapper.h"
     10#include "CanonicalPoly.h"
    1011
    1112PolyWrapper PolyWrapper::operator+ (const PolyWrapper& p) const
     
    1617  +prpr > "second argument = " < p.toString();
    1718  prpr-1;
    18   PolyWrapper q(this->getInternPoly()->deepCopy());  // deep copy of given PolyWrapper
     19  PolyWrapper q(this->getInternPoly()->deepCopy()); /* deep copy of given PolyWrapper */
    1920  q.getInternPoly()->add(p.getInternPoly());
    2021  return q;
     
    4445PolyWrapper::PolyWrapper (): m_pInternPoly(0)
    4546{
    46   assume(false); // the default constructor, i.e. the one
    47                  // without arguments should never be called
     47  assume(false); /* the default constructor, i.e. the one
     48                    without arguments should never be called */
    4849}
    4950
     
    113114}
    114115
    115 #endif // HAVE_WRAPPERS
     116PolyWrapper::PolyWrapper (const SingularPoly& sp, const RingWrapper& r) {
     117  +prpr > "creating a new PolyWrapper (internal type: CanonicalPoly)";
     118  m_pInternPoly = new CanonicalPoly(sp, r);
     119}
     120
     121#endif
     122/* HAVE_WRAPPERS */
  • Singular/PolyWrapper.h

    rbb503c7 ra388ae  
    44#ifdef HAVE_WRAPPERS
    55
     6#include "Wrappers.h"
    67#include "InternPoly.h"
    78#include "RingWrapper.h"
    8 #include "Wrappers.h"
    99
     10/*! \class PolyWrapper
     11 *  \brief Class PolyWrapper provides a uniform interface to different
     12 *         representations of polynomials.
     13 *
     14 *  Instances of PolyWrapper uniformly represent different kinds of
     15 *  polynomials that play a role in the computer algebra system SINGULAR
     16 *  and related suites such as PolyBoRi. Especially SINGULAR-internal
     17 *  polynomials can be wrapped by instances of PolyWrapper.<br>
     18 *  This implementation comes with an automatic reference counting so that copying
     19 *  PolyWrappers is cheap as it will simply be done by incrementing the
     20 *  respective reference counter. Constructors and destructors automatically
     21 *  manage the reference counting. Methods that create new instances of
     22 *  PolyWrapper, e.g. PolyWrapper::operator+ (const PolyWrapper& p) const,
     23 *  will internally enforce the instantiation of a new ReferenceCounter.<br>
     24 *  Summarizing this means that all methods of PolyWrapper <em>know</em> when
     25 *  to make a shallow copy (by incrementing the ReferenceCounter) and when to
     26 *  make a deep copy.<br>
     27 *  Polynomials wrapped by PolyWrapper <em>know</em> in which ring they live.
     28 *  A wrapper object of that ring can be obtained by calling
     29 *  PolyWrapper::getRing () const.
     30 *  \author Frank Seelisch, http://www.mathematik.uni-kl.de/~seelisch
     31 */
    1032class PolyWrapper
    1133{
    1234private:
     35  /*! a pointer to an internal polynomial representation,
     36      e.g. to a SINGULAR-internal polynomial */
    1337  InternPoly* m_pInternPoly;
     38 
     39  /*!
     40   *  A constructor for PolyWrapper.<br>
     41   *  This constructor just wraps the provided instance of InternPoly,
     42   *  which may e.g. be a SINGULAR-internal polynomial.
     43   *  @param ip the internal polynomial to be wrapped
     44   *  @see PolyWrapper::PolyWrapper ()
     45   *  @see PolyWrapper::PolyWrapper (const PolyWrapper& p)
     46   *  @see PolyWrapper::PolyWrapper (const int i, const RingWrapper& r)
     47   *  @see PolyWrapper::PolyWrapper (const SingularPoly& sp, const RingWrapper& r)
     48   */
    1449  PolyWrapper (InternPoly* ip);
     50 
     51  /*!
     52   *  A method for retrieving the wrapped InternPoly.
     53   *  @return the wrapped InternPoly
     54   *  @see PolyWrapper::PolyWrapper (InternPoly* ip)
     55   */
    1556  InternPoly* getInternPoly () const;
    1657public:
     58  /*!
     59   *  A default constructor for PolyWrapper.<br>
     60   *  This constructor will make the program stop as it should
     61   *  never be called by the user or as a side-effect of any action.
     62   *  @see PolyWrapper::PolyWrapper (InternPoly* ip)
     63   *  @see PolyWrapper::PolyWrapper (const PolyWrapper& p)
     64   *  @see PolyWrapper::PolyWrapper (const int i, const RingWrapper& r)
     65   *  @see PolyWrapper::PolyWrapper (const SingularPoly& sp, const RingWrapper& r)
     66   */
    1767  PolyWrapper ();
    18   PolyWrapper (const PolyWrapper& p);                // shallow copy
    19   PolyWrapper (const int i, const RingWrapper& r);   // integer i as a poly
     68
     69  /*!
     70   *  A copy constructor for PolyWrapper.<br>
     71   *  This constructor creates a shallow copy of the argument. This is
     72   *  simply done by incrementing the ReferenceCounter.
     73   *  @param p the PolyWrapper to be shallow-copied
     74   *  @see PolyWrapper::PolyWrapper ()
     75   *  @see PolyWrapper::PolyWrapper (InternPoly* ip)
     76   *  @see PolyWrapper::PolyWrapper (const int i, const RingWrapper& r)
     77   *  @see PolyWrapper::PolyWrapper (const SingularPoly& sp, const RingWrapper& r)
     78   */
     79  PolyWrapper (const PolyWrapper& p);
     80
     81  /*!
     82   *  A constructor for PolyWrapper.<br>
     83   *  This constructor creates a SINGULAR-internal polynomial representing
     84   *  the given argument integer, and then a wrapped version of it.<br>
     85   *  The user may use RingWrapper::RingWrapper () to create a RingWrapper wrapping
     86   *  the current SINGULAR-internal ring (<c>currRing</c>).
     87   *  @param i the integer to be represented as a polynomial
     88   *  @param r a RingWrapper wrapping the internal ring in which the polynomial lives
     89   *  @see PolyWrapper::PolyWrapper ()
     90   *  @see PolyWrapper::PolyWrapper (InternPoly* ip)
     91   *  @see PolyWrapper::PolyWrapper (const PolyWrapper& p)
     92   *  @see PolyWrapper::PolyWrapper (const SingularPoly& sp, const RingWrapper& r)
     93   */
     94  PolyWrapper (const int i, const RingWrapper& r);
     95 
     96  /*!
     97   *  A constructor for PolyWrapper.<br>
     98   *  This constructor creates a wrapped version of the given SINGULAR-internal
     99   *  polynomial.<br>
     100   *  The user may use RingWrapper::RingWrapper () to create a RingWrapper wrapping
     101   *  the current SINGULAR-internal ring (<c>currRing</c>).
     102   *  @param sp a SINGULAR-internal polynomial
     103   *  @param r a RingWrapper wrapping the internal ring in which the polynomial lives
     104   *  @see PolyWrapper::PolyWrapper ()
     105   *  @see PolyWrapper::PolyWrapper (InternPoly* ip)
     106   *  @see PolyWrapper::PolyWrapper (const PolyWrapper& p)
     107   *  @see PolyWrapper::PolyWrapper (const int i, const RingWrapper& r)
     108   */
     109  PolyWrapper (const SingularPoly& sp, const RingWrapper& r);
     110
     111  /*!
     112   *  A destructor for PolyWrapper.<br>
     113   *  This constructor creates a wrapped version of the given SINGULAR-internal
     114   *  polynomial.<br>
     115   *  This routine will automatically decrement the ReferenceCounter and, in case
     116   *  the counter reaches zero, enforce the destruction of related objects.
     117   *  @see PolyWrapper::PolyWrapper ()
     118   *  @see PolyWrapper::PolyWrapper (InternPoly* ip)
     119   *  @see PolyWrapper::PolyWrapper (const PolyWrapper& p)
     120   *  @see PolyWrapper::PolyWrapper (const int i, const RingWrapper& r)
     121   *  @see PolyWrapper::PolyWrapper (const SingularPoly& sp, const RingWrapper& r)
     122   */
    20123  ~PolyWrapper ();
     124 
     125  /*!
     126   *  A method for printing a string representation of the given instance.<br>
     127   *  This method does not use std::cout but only SINGULAR-internal print routines.
     128   *  @see PolyWrapper::printLn () const
     129   *  @see PolyWrapper::toString () const
     130   */
    21131  void print () const;
     132 
     133  /*!
     134   *  A method for printing a string representation of the given instance
     135   *  followed by a linefeed.<br>
     136   *  This method does not use std::cout but only SINGULAR-internal print routines.
     137   *  @see PolyWrapper::print () const
     138   *  @see PolyWrapper::toString () const
     139   */
    22140  void printLn () const;
     141
     142  /*!
     143   *  A method for obtaining a string representation of the given instance.
     144   *  @see PolyWrapper::print () const
     145   *  @see PolyWrapper::printLn () const
     146   */
    23147  char* toString () const;
     148 
     149  /*!
     150   *  Assignment operator for PolyWrapper.<br>
     151   *  This method will just exchange the wrapped instance of InternPoly.
     152   *  Consequently, the ReferenceCounter of the InternPoly wrapped by the
     153   *  given argument will be decremented (and in case of reaching zero,
     154   *  the destruction of related objects will be enforced).
     155   *  @param p an instance of PolyWrapper
     156   *  @return a reference to the new PolyWrapper
     157   */
    24158  PolyWrapper& operator= (const PolyWrapper& p);
     159 
     160  /*!
     161   *  Addition operator for PolyWrapper.<br>
     162   *  This method will compute a PolyWrapper which wraps the result of
     163   *  adding the polynomials wrapped by <c>this</c> PolyWrapper and by
     164   *  the argument PolyWrapper.
     165   *  @param p an instance of PolyWrapper
     166   *  @return a PolyWrapper representing the sum
     167   */
    25168  PolyWrapper operator+ (const PolyWrapper& p) const;
     169
     170  /*!
     171   *  Modifying addition operator for PolyWrapper.<br>
     172   *  This method will compute (in the PolyWrapper given by <c>this</c>),
     173   *  the result of adding the polynomials wrapped by <c>this</c> PolyWrapper and by
     174   *  the argument PolyWrapper. Note that this method will in general change the
     175   *  given object.
     176   *  @param p an instance of PolyWrapper
     177   *  @return a reference to <c>this</c> PolyWrapper now representing the sum
     178   */
    26179  PolyWrapper& operator+= (const PolyWrapper& p);
     180 
     181  /*!
     182   *  A method for retrieving a RingWrapper wrapping the internal ring in which
     183   *  the given polynomial lives.
     184   *  @return a reference to a RingWrapper
     185   */
    27186  const RingWrapper& getRing () const;
    28187};
    29188
    30 #endif // HAVE_WRAPPERS
     189#endif
     190/* HAVE_WRAPPERS */
    31191
    32192#endif
  • Singular/PrettyPrinter.cc

    rbb503c7 ra388ae  
    88#include "PrettyPrinter.h"
    99
    10 PrettyPrinter::PrettyPrinter (const char* fileName1, const char* fileName2,   // choose filename "" for no output file
     10PrettyPrinter::PrettyPrinter (const char* fileName1, const char* fileName2,
    1111                              const bool append1, const bool append2,
    1212                              const int console, const char* baseIndent)
     
    4848{
    4949  if (strcmp(m_fileName1, "") != 0)
    50   {
    51     m_file1 << s;
    52   }
     50    m_file1 << s;
    5351  if (m_console == 0 || m_console == 1)
    54   {
    55     PrintS(s);
    56   }
     52    PrintS(s);
    5753  return *this;
    5854}
     
    6157{
    6258  if (strcmp(m_fileName1, "") != 0)
    63   {
    64     m_file1 << s;
    65   }
    66   if (strcmp(m_fileName2, "") != 0)
    67   {
     59    m_file1 << s;
     60  if (strcmp(m_fileName2, "") != 0)
    6861    m_file2 << s;
    69   }
    7062  if (m_console == 0 || m_console == 1 || m_console == 2)
    71   {
    72     PrintS(s);
    73   }
     63    PrintS(s);
    7464  return *this;
    7565}
     
    180170
    181171PrettyPrinter& PrettyPrinter::operator+ ()
    182 {
    183   if (strcmp(m_fileName1, "") != 0)
    184   {
     172{                                                                 
     173  if (strcmp(m_fileName1, "") != 0)
    185174    m_file1 << "\n";
    186   }
    187175  if (m_console == 0 || m_console == 1)
    188   {
    189176    PrintLn();
    190   }
    191177  return *this;
    192178}
     
    195181{
    196182  if (strcmp(m_fileName1, "") != 0)
    197   {
    198183    m_file1 << "\n";
    199   }
    200   if (strcmp(m_fileName2, "") != 0)
    201   {
     184  if (strcmp(m_fileName2, "") != 0)
    202185    m_file2 << "\n";
    203   }
    204186  if (m_console == 0 || m_console == 1 || m_console == 2)
    205   {
    206187    PrintLn();
    207   }
    208188  return *this;
    209189}
     
    286266}
    287267
    288 #endif // defined(HAVE_MINOR) || defined(HAVE_WRAPPERS)
     268#endif
     269/* defined(HAVE_MINOR) || defined(HAVE_WRAPPERS) */
  • Singular/PrettyPrinter.h

    rbb503c7 ra388ae  
    77#include <string>
    88
     9/*! \class PrettyPrinter
     10 *  \brief Class PrettyPrinter is a utility for pretty-printing any kind of
     11 *         output to one or two files and/or the console.
     12 *
     13 *  The user may use an instance of PrettyPrinter to define two files to
     14 *  which output can be directed. Then, whenever an item is written to the
     15 *  PrettyPrinter, the user can decide whether the output goes only to the
     16 *  first of the files or to both. Thereby, the user may write, e.g., <em>all</em>
     17 *  output to the first file, and only <em>asorted</em> parts to the second, e.g.,
     18 *  only the most important bits, for instance to generate some kind of overview
     19 *  of the data that is written to the first file.<br>
     20 *  Furthermore, the user can decide whether the output will also go to the
     21 *  console. If so, he/she can decide whether the console will display
     22 *  all that output which goes to the first file, or only that which goes
     23 *  to the second one.
     24 *  Moreover, PrettyPrinter offers functionality to easily include linefeeds
     25 *  and tabs in the output to give it a better readable format.
     26 *  \author Frank Seelisch, http://www.mathematik.uni-kl.de/~seelisch
     27 */
    928class PrettyPrinter
    1029{
    1130private:
     31  /*! the number of times, the m_baseIndent is used to make up the current
     32      indent string; see e.g. PrettyPrinter::operator> (const char* s);
     33      Example: if m_baseIndent is "~~~" and m_indents == 2, then the current
     34      indent string is set to "~~~~~~" */
    1235  int m_indents;
     36
     37  /*! the base string to define the entire current indent string;
     38      see description of m_indents */
    1339  char* m_baseIndent;
     40
     41  /*! the container for the entire current indent string;
     42      see descriptions of m_indents and m_baseIndent */
    1443  char* m_indent;
    15   char* m_fileName1;    // file name for outputs to primary output file
    16   char* m_fileName2;    // file name for outputs to secondary output file
    17   int m_console;        // == -1: no output to console
    18                         // == 0:  just output to console, i.e. no file output
    19                         // == 1:  identical outputs to file1 and console;
    20                         // == 2:  identical outputs to file2 and console;
    21                         // (file1 contains at least as much output as file2)
     44
     45  /*! file name of primary output file m_file1;
     46      m_file1 will always contain at least as much output as m_file2 */
     47  char* m_fileName1;
     48
     49  /*! file name of secondary output file m_file2;
     50      m_file1 will always contain at least as much output as m_file2 */
     51  char* m_fileName2;
     52
     53  /*! for controlling output to the console;<br>
     54      if == -1: no output to the console<br>
     55      if == 0:  just output to the console, i.e. no file output<br>
     56      if == 1:  identical outputs to file1 and console<br>
     57      if == 2:  identical outputs to file2 and console */
     58  int m_console;
     59
     60  /*! file handle to primary output file */
    2261  std::ofstream m_file1;
     62
     63  /*! file handle to secondary output file */
    2364  std::ofstream m_file2;
    2465public:
    25   PrettyPrinter (const char* fileName1, const char* fileName2,   // choose filename "" for no output file
     66  /*!
     67   *  A constructor for PrettyPrinter.<br>
     68   *  Set filenames equal to "" in order to omit the usage of that file. I.e.,
     69   *  the user should set fileName2 to "" when he/she wants to use only one
     70   *  output file and set both filenames to "" when he/she does not want any file output.<br>
     71   *  Set console to -1, if no console output is desired; to 0 if there should be
     72   *  console output but no file output; to 1 if console output should be identical to
     73   *  output to primary file; and to 2 if console output should be identical to
     74   *  output to secondary file.<br>
     75   *  The baseIndent will be used to build the current indent string which will be included
     76   *  in the output using e.g. PrettyPrinter::operator> (const char* s).
     77   *  @param fileName1 a file name for the primary output file
     78   *  @param fileName2 a file name for the secondary output file
     79   *  @param append1 if true, m_file1 is being appended, otherwise initially cleared
     80   *  @param append2 if true, m_file2 is being appended, otherwise initially cleared
     81   *  @param console control integer for setting up console output
     82   *  @param baseIndent the base string for the indent string
     83   *  @see PrettyPrinter::operator+ (const int i)
     84   */
     85  PrettyPrinter (const char* fileName1, const char* fileName2,
    2686                 const bool append1, const bool append2,
    2787                 const int console, const char* baseIndent);
     88
     89  /*!
     90   *  A destructor for PrettyPrinter.
     91   */
    2892  ~PrettyPrinter ();
     93 
     94  /*!
     95   *  A method for including a linefeed in the output to the primary file
     96   *  (if any) and to the console (if console output has been declared accordingly).
     97   *  @return a reference to the modified instance of PrettyPrinter
     98   *  @see PrettyPrinter::operator++ ()
     99   */
    29100  PrettyPrinter& operator+ ();
     101 
     102  /*!
     103   *  A method for including a linefeed in the output to the primary file
     104   *  (if any), the secondary file (if any), and to the console (if console
     105   *  output has been declared accordingly).
     106   *  @return a reference to the modified instance of PrettyPrinter
     107   *  @see PrettyPrinter::operator+ ()
     108   */
    30109  PrettyPrinter& operator++ ();
     110 
     111  /*!
     112   *  A method for including the current indent string followed by the argument string
     113   *  in the output to the primary file (if any) and to the console (if console output
     114   *  has been declared accordingly).
     115   *  @param s the string to be written to the output devices
     116   *  @return a reference to the modified instance of PrettyPrinter
     117   *  @see PrettyPrinter::operator>> (const char* s)
     118   */
    31119  PrettyPrinter& operator> (const char* s);
     120
     121  /*!
     122   *  A method for including the current indent string followed by the argument string
     123   *  in the output to the primary file (if any), to the secondary file (if any), and to
     124   *  the console (if console output has been declared accordingly).
     125   *  @param s the string to be written to the output devices
     126   *  @return a reference to the modified instance of PrettyPrinter
     127   *  @see PrettyPrinter::operator> (const char* s)
     128   */
    32129  PrettyPrinter& operator>> (const char* s);
     130
     131  /*!
     132   *  A method for including the current indent string followed by the argument integer
     133   *  in the output to the primary file (if any) and to the console (if console output
     134   *  has been declared accordingly).
     135   *  @param i the integer to be written to the output devices
     136   *  @return a reference to the modified instance of PrettyPrinter
     137   *  @see PrettyPrinter::operator>> (const int i)
     138   */
    33139  PrettyPrinter& operator> (const int i);
     140 
     141  /*!
     142   *  A method for including the current indent string followed by the argument integer
     143   *  in the output to the primary file (if any), to the secondary file (if any), and to
     144   *  the console (if console output has been declared accordingly).
     145   *  @param i the integer to be written to the output devices
     146   *  @return a reference to the modified instance of PrettyPrinter
     147   *  @see PrettyPrinter::operator> (const int i)
     148   */
    34149  PrettyPrinter& operator>> (const int i);
     150 
     151  /*!
     152   *  A method for including the current indent string followed by the argument long
     153   *  in the output to the primary file (if any) and to the console (if console output
     154   *  has been declared accordingly).
     155   *  @param l the long to be written to the output devices
     156   *  @return a reference to the modified instance of PrettyPrinter
     157   *  @see PrettyPrinter::operator>> (const long l)
     158   */
    35159  PrettyPrinter& operator> (const long l);
     160 
     161  /*!
     162   *  A method for including the current indent string followed by the argument long
     163   *  in the output to the primary file (if any), to the secondary file (if any), and to
     164   *  the console (if console output has been declared accordingly).
     165   *  @param l the long to be written to the output devices
     166   *  @return a reference to the modified instance of PrettyPrinter
     167   *  @see PrettyPrinter::operator> (const long l)
     168   */
    36169  PrettyPrinter& operator>> (const long l);
     170 
     171  /*!
     172   *  A method for including the current indent string followed by the argument unsigned long
     173   *  in the output to the primary file (if any) and to the console (if console output
     174   *  has been declared accordingly).
     175   *  @param ul the unsigned long to be written to the output devices
     176   *  @return a reference to the modified instance of PrettyPrinter
     177   *  @see PrettyPrinter::operator>> (const unsigned long ul)
     178   */
    37179  PrettyPrinter& operator> (const unsigned long ul);
     180 
     181  /*!
     182   *  A method for including the current indent string followed by the argument unsigned long
     183   *  in the output to the primary file (if any), to the secondary file (if any), and to
     184   *  the console (if console output has been declared accordingly).
     185   *  @param ul the unsigned long to be written to the output devices
     186   *  @return a reference to the modified instance of PrettyPrinter
     187   *  @see PrettyPrinter::operator> (const unsigned long ul)
     188   */
    38189  PrettyPrinter& operator>> (const unsigned long ul);
     190 
     191  /*!
     192   *  A method for including the current indent string followed by the argument string
     193   *  in the output to the primary file (if any) and to the console (if console output
     194   *  has been declared accordingly).
     195   *  @return a reference to the modified instance of PrettyPrinter
     196   *  @see PrettyPrinter::operator>> (const std::string s)
     197   */
    39198  PrettyPrinter& operator> (const std::string s);
     199 
     200  /*!
     201   *  A method for including the current indent string followed by the argument string
     202   *  in the output to the primary file (if any), to the secondary file (if any), and to
     203   *  the console (if console output has been declared accordingly).
     204   *  @param s the string to be written to the output devices
     205   *  @return a reference to the modified instance of PrettyPrinter
     206   *  @see PrettyPrinter::operator> (const std::string s)
     207   */
    40208  PrettyPrinter& operator>> (const std::string s);
     209 
     210  /*!
     211   *  A method for including the argument string in the output to the primary file
     212   *  (if any) and to the console (if console output has been declared accordingly).
     213   *  @param s the string to be written to the output devices
     214   *  @return a reference to the modified instance of PrettyPrinter
     215   *  @see PrettyPrinter::operator<< (const char* s)
     216   */
    41217  PrettyPrinter& operator< (const char* s);
     218 
     219  /*!
     220   *  A method for including the argument string in the output to the primary file
     221   *  (if any), to the secondary file (if any), and to the console (if console
     222   *  output has been declared accordingly).
     223   *  @param s the string to be written to the output devices
     224   *  @return a reference to the modified instance of PrettyPrinter
     225   *  @see PrettyPrinter::operator< (const char* s)
     226   */
    42227  PrettyPrinter& operator<< (const char* s);
     228 
     229  /*!
     230   *  A method for including the argument integer in the output to the primary file
     231   *  (if any) and to the console (if console output has been declared accordingly).
     232   *  @param i the integer to be written to the output devices
     233   *  @return a reference to the modified instance of PrettyPrinter
     234   *  @see PrettyPrinter::operator<< (const int i)
     235   */
    43236  PrettyPrinter& operator< (const int i);
     237 
     238  /*!
     239   *  A method for including the argument integer in the output to the primary file
     240   *  (if any), to the secondary file (if any), and to the console (if console
     241   *  output has been declared accordingly).
     242   *  @param i the integer to be written to the output devices
     243   *  @return a reference to the modified instance of PrettyPrinter
     244   *  @see PrettyPrinter::operator< (const int i)
     245   */
    44246  PrettyPrinter& operator<< (const int i);
     247 
     248  /*!
     249   *  A method for including the argument long in the output to the primary file
     250   *  (if any) and to the console (if console output has been declared accordingly).
     251   *  @param l the long to be written to the output devices
     252   *  @return a reference to the modified instance of PrettyPrinter
     253   *  @see PrettyPrinter::operator<< (const long l)
     254   */
    45255  PrettyPrinter& operator< (const long l);
     256
     257  /*!
     258   *  A method for including the argument long in the output to the primary file
     259   *  (if any), to the secondary file (if any), and to the console (if console
     260   *  output has been declared accordingly).
     261   *  @param l the long to be written to the output devices
     262   *  @return a reference to the modified instance of PrettyPrinter
     263   *  @see PrettyPrinter::operator< (const long l)
     264   */
    46265  PrettyPrinter& operator<< (const long l);
     266 
     267  /*!
     268   *  A method for including the argument unsigned long in the output to the primary file
     269   *  (if any) and to the console (if console output has been declared accordingly).
     270   *  @param ul the unsigned long to be written to the output devices
     271   *  @return a reference to the modified instance of PrettyPrinter
     272   *  @see PrettyPrinter::operator<< (const unsigned long ul)
     273   */
    47274  PrettyPrinter& operator< (const unsigned long ul);
     275 
     276  /*!
     277   *  A method for including the argument unsigned long in the output to the primary file
     278   *  (if any), to the secondary file (if any), and to the console (if console
     279   *  output has been declared accordingly).
     280   *  @param ul the unsigned long to be written to the output devices
     281   *  @return a reference to the modified instance of PrettyPrinter
     282   *  @see PrettyPrinter::operator< (const unsigned long ul)
     283   */
    48284  PrettyPrinter& operator<< (const unsigned long ul);
     285 
     286  /*!
     287   *  A method for including the argument string in the output to the primary file
     288   *  (if any) and to the console (if console output has been declared accordingly).
     289   *  @param s the string to be written to the output devices
     290   *  @return a reference to the modified instance of PrettyPrinter
     291   *  @see PrettyPrinter::operator<< (const std::string s)
     292   */
    49293  PrettyPrinter& operator< (const std::string s);
     294 
     295  /*!
     296   *  A method for including the argument string in the output to the primary file
     297   *  (if any), to the secondary file (if any), and to the console (if console
     298   *  output has been declared accordingly).
     299   *  @param s the string to be written to the output devices
     300   *  @return a reference to the modified instance of PrettyPrinter
     301   *  @see PrettyPrinter::operator< (const std::string s)
     302   */
    50303  PrettyPrinter& operator<< (const std::string s);
     304
     305  /*!
     306   *  A method for incrementing the number of times the baseIndent string is
     307   *  concatenated in order to form the current entire indent string. The increment equals
     308   *  the argument integer.<br>
     309   *  Use PrettyPrinter::setBaseIndent (const char* baseIndent) to define the
     310   *  baseIndent string. If e.g. baseIndent == "~~", and the incremented number of times
     311   *  this baseIndent will be used equals 3, then the current indent string will be set to
     312   *  "~~~~~~".
     313   *  @param i the number of times the baseIndent is use to form the current indent string
     314   *  @return a reference to the modified instance of PrettyPrinter
     315   *  @see PrettyPrinter::operator- (const int i)
     316   */
    51317  PrettyPrinter& operator+ (const int i);
     318 
     319  /*!
     320   *  A method for decrementing the number of times the baseIndent string is
     321   *  concatenated in order to form the current entire indent string. The decrement equals
     322   *  the argument integer.<br>
     323   *  Use PrettyPrinter::setBaseIndent (const char* baseIndent) to define the
     324   *  baseIndent string. If e.g. baseIndent == "~~", and the decremented number of times
     325   *  this baseIndent will be used equals 3, then the current indent string will be set to
     326   *  "~~~~~~".
     327   *  @param i the number of times the baseIndent is use to form the current indent string
     328   *  @return a reference to the modified instance of PrettyPrinter
     329   *  @see PrettyPrinter::operator+ (const int i)
     330   */
    52331  PrettyPrinter& operator- (const int i);
     332
     333  /*!
     334   *  A method for setting the baseIndent string.<br>
     335   *  Note that this string is used to form the current entire indent string.
     336   *  @param baseIndent the new baseIndent string
     337   *  @return a reference to the modified instance of PrettyPrinter
     338   *  @see PrettyPrinter::getBaseIndent () const
     339   */
    53340  void setBaseIndent (const char* baseIndent);
     341 
     342  /*!
     343   *  A method for retrieving the baseIndent string.<br>
     344   *  Note that this string is used to form the current entire indent string.
     345   *  @return the current baseIndent string
     346   *  @see PrettyPrinter::setBaseIndent (const char* baseIndent)
     347   */
    54348  char* getBaseIndent () const;
     349
     350  /*!
     351   *  A method for controling console output.<br>
     352   *  Use the parameter -1, if no console output is desired; 0 if there should be
     353   *  console output but no file output; 1 if console output should be identical to
     354   *  output to the primary file; and 2 if console output should be identical to
     355   *  output to the secondary file.
     356   *  @param console the control number as described in the method comment
     357   *  @see PrettyPrinter::getConsole () const
     358   */
    55359  void setConsole (const int console);
     360 
     361  /*!
     362   *  A method for retrieving the console output control parameter.<br>
     363   *  @see PrettyPrinter::setConsole (const int console)
     364   */
    56365  int getConsole () const;
    57366};
    58367
    59 #endif // defined(HAVE_MINOR) || defined(HAVE_WRAPPERS)
     368#endif
     369/* defined(HAVE_MINOR) || defined(HAVE_WRAPPERS) */
    60370
    61371#endif
  • Singular/ReferenceCounter.cc

    rbb503c7 ra388ae  
    33#ifdef HAVE_WRAPPERS
    44
     5#include <iostream>
     6#include "Wrappers.h"
    57#include "ReferenceCounter.h"
    6 #include "Wrappers.h"
    7 #include <iostream>
    88
    9 refcount_type ReferenceCounter::decrement ()
     9ReferenceCounterType ReferenceCounter::decrement ()
    1010{
    11   assume(m_counter > 0); // Ensure positivity of counter
     11  assume(m_counter > 0); /* ensure positivity of counter */
    1212  +prpr > "ReferenceCounter decremented to " < m_counter - 1;
    1313  return --m_counter;
    14 };
     14}
    1515
    16 refcount_type ReferenceCounter::increment ()
     16ReferenceCounterType ReferenceCounter::increment ()
    1717{
    1818  +prpr > "ReferenceCounter incremented to " < m_counter + 1;
     
    2626
    2727ReferenceCounter::ReferenceCounter (const ReferenceCounter& rc)
    28 {
     28{                           
    2929  assume(false); /* copy constructor should never be called */
    3030}
     
    3535}
    3636
    37 refcount_type ReferenceCounter::getCounter () const
     37ReferenceCounterType ReferenceCounter::getCounter () const
    3838{
    3939  return m_counter;
     
    4545}
    4646
    47 #endif // HAVE_WRAPPERS
     47#endif
     48/* HAVE_WRAPPERS */
  • Singular/ReferenceCounter.h

    rbb503c7 ra388ae  
    44#ifdef HAVE_WRAPPERS
    55
    6 /// Set type for storing reference counter
    7 typedef unsigned long refcount_type;
     6#include "Wrappers.h"
    87
     8/*! \class ReferenceCounter
     9 *  \brief Class ReferenceCounter may be used to derive classes from it
     10 *         which deploy reference counting.
     11 *
     12 *  Any instance of a class, say C, derived from ReferenceCounter is
     13 *  equipped with a counter that stores how many instances of C exist.
     14 *  Thereby, it becomes possible to better manage instances of C and
     15 *  make shallow copies of instances of C by simply incrementing the
     16 *  reference counter (which is a member of the superclass of C, i.e.,
     17 *  of ReferenceCounter).
     18 *  \author Frank Seelisch, http://www.mathematik.uni-kl.de/~seelisch
     19 */
    920class ReferenceCounter {
    1021private:
    11   /// Store reference counter
    12   refcount_type m_counter;
     22  /*! private member for storing the actual reference counter */
     23  ReferenceCounterType m_counter;
     24protected:
     25  /*!
     26   *  A method for retrieving the actual reference counter.
     27   *  @return the actual reference counter
     28   */
     29  ReferenceCounterType getCounter () const;
     30
     31  /*!
     32   *  A method for retrieving whether the reference counter is
     33   *  greater than 1. In this case, at least two references to the given
     34   *  instance of ReferenceCounter exist.
     35   *  @return true if the reference counter is greater than 1
     36   */
     37  bool isShared () const;
     38
     39  /*!
     40   *  A method for incrementing the reference counter.
     41   *  @return the value of the reference counter after incrementing
     42   *  @see ReferenceCounterType::decrement ();
     43   */
     44  ReferenceCounterType increment ();
     45
     46  /*!
     47   *  A method for decrementing the reference counter.
     48   *  @return the value of the reference counter after decrementing
     49   *  @see ReferenceCounterType::increment ();
     50   */
     51  ReferenceCounterType decrement ();
    1352public:
     53  /*!
     54   *  A constructor for ReferenceCounter.<br>
     55   *  This constructor will create a new instance with actual
     56   *  reference counter set to zero.
     57   */
    1458  ReferenceCounter ();
    1559
    16   /// Deep copy
     60  /*!
     61   *  A copy constructor for ReferenceCounter.<br>
     62   *  As this constructor should neither be called by the user nor
     63   *  implicitely by some method, it will halt the program.
     64   */
    1765  ReferenceCounter (const ReferenceCounter& rc);
    1866
    19   /// Destructor
     67  /*!
     68   *  A destructor for ReferenceCounter.
     69   */
    2070  ~ReferenceCounter ();
    21 
    22   /// Get reference counter
    23   refcount_type getCounter () const;
    24 
    25   /// Check, whether reference is used multiple times
    26   bool isShared () const;
    27 
    28   /// Increase reference counter
    29   refcount_type increment ();
    30 
    31   /// Decrease reference counter
    32   refcount_type decrement ();
     71/*! We enable PolyWrapper to "see" all methods of ReferenceCounter. */
     72friend class PolyWrapper;
    3373};
    3474
    35 #endif // HAVE_WRAPPERS
     75#endif
     76/* HAVE_WRAPPERS */
    3677
    3778#endif
  • Singular/RingWrapper.cc

    rbb503c7 ra388ae  
    33#ifdef HAVE_WRAPPERS
    44
     5#include <iostream>
     6#include <stdio.h>
     7#include <string.h>
     8#include "febase.h"
    59#include "ipshell.h"
    610#include "grammar.h"
    711#include "ipid.h"
    812#include "polys.h"
    9 #include <iostream>
     13#include "Wrappers.h"
    1014#include "RingWrapper.h"
    11 #include "Wrappers.h"
    12 #include <stdio.h>
    13 #include <string.h>
    14 #include "febase.h"
    1515
    1616RingWrapper::RingWrapper (const char* ringName, const int characteristic,
     
    3030  m_singularRing->block0 = (int *)omAlloc0(2 * sizeof(int *));
    3131  m_singularRing->block1 = (int *)omAlloc0(2 * sizeof(int *));
    32   /* ringorder 'ringOrder' for the first block: var 1..N */
     32  /* ringorder 'ringOrder' for the first block: var 1..varNumber */
    3333  if (strcmp(ringOrder, "dp") == 0) m_singularRing->order[0]  = ringorder_dp;
    3434  if (strcmp(ringOrder, "lp") == 0) m_singularRing->order[0]  = ringorder_lp;
     
    4141  /* the last block: everything is 0 */
    4242  m_singularRing->order[1]  = 0;
    43   /*polynomial ring*/
     43  /* polynomial ring */
    4444  m_singularRing->OrdSgn    = 1;
    4545
     
    5050RingWrapper::RingWrapper ()
    5151{
    52   assume(false); // the default constructor, i.e. the one
    53                  // without arguments should never be called
     52  +prpr > "creating a new RingWrapper (internal type: SINGULAR ring)";
     53  m_singularRing = currRing;
    5454}
    5555
     
    6666  int n = rVar(m_singularRing);
    6767  if (ch == 0)
    68   {
    6968    strcat(str, "Q");
    70   }
    7169  else
    7270  {
     
    7674  }
    7775  strcat(str, "[");
    78   for (int i = 0; i < n; i++) {
     76  for (int i = 0; i < n; i++)
     77  {
    7978    if (i > 0) strcat(str, ",");
    8079    strcat(str, m_singularRing->names[i]);
     
    114113}
    115114
    116 #endif // HAVE_WRAPPERS
     115#endif
     116/* HAVE_WRAPPERS */
  • Singular/RingWrapper.h

    rbb503c7 ra388ae  
    77#include "Wrappers.h"
    88
     9/*! \class RingWrapper
     10 *  \brief Class RingWrapper provides a uniform interface to different
     11 *         representations of rings.
     12 *
     13 *  Instances of RingWrapper uniformly represent different kinds of
     14 *  rings that play a role in the computer algebra system SINGULAR
     15 *  and related suites such as PolyBoRi. Especially SINGULAR-internal
     16 *  rings can be wrapped by instances of RingWrapper.<br>
     17 *  This is just a first implementation, so far for wrapping SINGULAR-internal
     18 *  rings only.<br>
     19 *  An important feature of RingWrapper is the check whether two given rings
     20 *  (wrapped as instances of RingWrapper) are compatible with respect to
     21 *  basic arithmetics; such as PolyWrapper::operator+ (const PolyWrapper& p) const.
     22 *  \author Frank Seelisch, http://www.mathematik.uni-kl.de/~seelisch
     23 */
    924class RingWrapper
    1025{
    1126private:
     27  /*! a member for storing a SINGULAR-internal ring;
     28      note that this is not just a reference to but an instance
     29      of a SINGULAR-internal ring */
    1230  SingularRing m_singularRing;
    1331public:
     32  /*!
     33   *  A constructor for RingWrapper.<br>
     34   *  This constructor builds a SINGULAR-internal ring with a given
     35   *  name, characteristic and list of variables. The monomial order
     36   *  must also be provided and must be one of {dp, lp, Dp, ds, ls, Ds}.
     37   *  @param ringName the name of the wrapped SINGULAR-internal ring
     38   *  @param characteristic the characteristic of the wrapped SINGULAR-internal ring
     39   *  @param varNumber the number of variables in the wrapped SINGULAR-internal ring
     40   *  @param varNames the array of names of variables in the wrapped SINGULAR-internal ring
     41   *  @param ringOrder one of {dp, lp, Dp, ds, ls, Ds}
     42   *  @see RingWrapper::RingWrapper ()
     43   */
    1444  RingWrapper (const char* ringName, const int characteristic,
    1545               const int varNumber, const char** varNames, const char* ringOrder);
     46               
     47  /*!
     48   *  A default constructor for RingWrapper.<br>
     49   *  This constructor wraps the current SINGULAR-internal ring which is
     50   *  assumed to use one of the monomial orderings of {dp, lp, Dp, ds, ls, Ds}.
     51   *  @see RingWrapper::RingWrapper (const char* ringName, const int characteristic,
     52                                     const int varNumber, const char** varNames, const char* ringOrder)
     53   */
    1654  RingWrapper ();
     55 
     56  /*!
     57   *  A destructor for RingWrapper.<br>
     58   *  Since the private member is an instance of a SINGULAR-internal ring and not
     59   *  a reference, the destructor for this SINGULAR-internal ring will be called.
     60   *  @see RingWrapper::RingWrapper ()
     61   *  @see RingWrapper::RingWrapper (const char* ringName, const int characteristic,
     62                                     const int varNumber, const char** varNames, const char* ringOrder)
     63   */
    1764  ~RingWrapper ();
     65
     66  /*!
     67   *  A method for printing a string representation of the given instance.<br>
     68   *  This method does not use std::cout but only SINGULAR-internal print routines.
     69   *  @see RingWrapper::printLn () const
     70   *  @see RingWrapper::toString () const
     71   */
    1872  void print () const;
     73 
     74  /*!
     75   *  A method for printing a string representation of the given instance
     76   *  followed by a linefeed.<br>
     77   *  This method does not use std::cout but only SINGULAR-internal print routines.
     78   *  @see RingWrapper::print () const
     79   *  @see RingWrapper::toString () const
     80   */
    1981  void printLn () const;
     82 
     83  /*!
     84   *  A method for obtaining a string representation of the given instance.
     85   *  @see RingWrapper::print () const
     86   *  @see RingWrapper::printLn () const
     87   */
    2088  char* toString () const;
     89
     90  /*!
     91   *  A method for checking whether two wrapped rings are compatible with
     92   *  respect to basic arithmetics such as PolyWrapper::operator+ (const PolyWrapper& p)
     93   *  @param r another RingWrapper
     94   *  @return true if the tow wrpaped rings are compatible
     95   */
    2196  bool isCompatible (const RingWrapper& r) const;
     97 
     98  /*!
     99   *  A method for retrieving the wrapped SINGULAR-internal ring.
     100   *  @return the wrapped SINGULAR-internal ring
     101   */
    22102  const SingularRing& getSingularRing () const;
    23103};
    24104
    25 #endif // HAVE_WRAPPERS
     105#endif
     106/* HAVE_WRAPPERS */
    26107
    27108#endif
  • Singular/Wrappers.cc

    rbb503c7 ra388ae  
    44
    55#include <iostream>
     6#include "febase.h"
     7#include "Wrappers.h"
    68#include "RingWrapper.h"
    79#include "PolyWrapper.h"
    8 #include "Wrappers.h"
    9 #include "febase.h"
    1010
     11void test0 ();
    1112void test1 ();
    1213void test2 ();
    1314void test3 ();
     15void test4 ();
    1416
    1517PrettyPrinter 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}
    1634
    1735void testWrappers (bool detailedOutput)
     
    2038  prpr+1;
    2139
     40  test0();
    2241  test1();
    2342  test2();
    2443  test3();
     44  test4();
    2545
    2646  prpr-1;
     
    2949}
    3050
     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
    3163void test1 ()
    3264{
    3365  PrintLn();
    3466  PrintS("Test1: Creation and destruction of instances of RingWrapper");
     67
    3568  const char* theVariables1[2] = {"x", "y"};
    3669  RingWrapper r1("myRing1", 7, 2, theVariables1, "dp");
    3770  PrintLn(); PrintS("r1 = "); r1.print();
     71 
    3872  const char* theVariables2[3] = {"u", "v", "w"};
    3973  RingWrapper r2("myRing2", 0, 3, theVariables2, "Ds");
     
    4579  PrintLn();
    4680  PrintS("Test2: Creation, copying, assignment, and destruction of instances of PolyWrapper");
     81 
    4782  const char* theVariables[2] = {"x", "y"};
    4883  RingWrapper r("myRing", 0, 2, theVariables, "lp");
    4984  PrintLn(); PrintS("r = "); r.print();
     85 
    5086  PolyWrapper p1(4, r);
    5187  PrintLn(); PrintS("p1 = "); p1.print();
     
    6399{
    64100  PrintLn();
    65   PrintS("Test3: Addition of instances of PolyWrapper");
     101  PrintS("Test3: Addition of compatible instances of PolyWrapper");
     102 
    66103  const char* theVariables[2] = {"x", "y"};
    67104  RingWrapper r("myRing", 0, 2, theVariables, "Ds");
    68105  PrintLn(); PrintS("r = "); r.print();
     106 
    69107  PolyWrapper p1(4, r);
    70108  PrintLn(); PrintS("p1 = "); p1.print();
     
    75113  p3 = p1;
    76114  PrintLn(); PrintS("p3 = "); p3.print();
    77   p3 += p2;  // this should change p3 but NOT p2!
     115  p3 += p2;  /* this should change p3 but NOT p2! */
    78116  PrintLn(); PrintS("p3 = "); p3.print();
    79117  PrintLn(); PrintS("p2 = "); p2.print();
    80118}
    81119
    82 #endif // HAVE_WRAPPERS
     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 */
  • Singular/Wrappers.h

    rbb503c7 ra388ae  
    88#include "PrettyPrinter.h"
    99
     10/*! \mainpage C++ wrappers for SINGULAR and related systems
     11 *
     12 *  \section design Design Overview
     13 *  The following picture shows a UML-like design of the classes implemented so far,
     14 *  and their relationship.
     15 *  \image html "file:///C:/Work/C++Code/inside SINGULAR/C++Wrappers/Overview1.jpg"
     16 *
     17 *  \section howto How to run this code inside SINGULAR
     18 *  The following steps need to be done to run the C++ wrapper code inside SINGULAR:<br><br>
     19 *  Re-build and run SINGULAR:<br>
     20 *  - checkout the latest code and compile SINGULAR,<br>
     21 *  - go to <c>/SINGULAR</c> and perform <c>make clean</c>,<br>
     22 *  - go to <c>/kernel</c> and perform <c>make clean</c>,<br>
     23 *  - open <c>/SINGULAR/mod2.h</c> and include the line <c>#define HAVE_WRAPPERS 1</c>,<br>
     24 *  - open <c>/kernel/mod2.h</c> and include the line <c>#define HAVE_WRAPPERS 1</c>,<br>
     25 *  - go to <c>/SINGULAR</c> and perform <c>make</c>,<br>
     26 *  - go to <c>/kernel</c> and perform <c>make</c> (Now you have a runnable SINGULAR version
     27 *    including the C++ wrapper code.),<br>
     28 *  - go to <c>/SINGULAR</c> and perform <c>./Singular</c> to run the newly built local
     29 *    executable<br>
     30 *
     31 *  Call the new code:<br>
     32 *  - you may first declare a ring, e.g. by typing <c>ring r;</c>,<br>
     33 *  - type <c>system("c++wrappers", 0);</c> to perform <c>testWrappers</c> (see file Wrappers.h) without
     34 *    detailed printout to the console,<br>
     35 *  - type <c>system("c++wrappers", 1);</c> to perform <c>testWrappers</c> (see file Wrappers.h) with
     36 *    detailed printout to the console,<br>
     37 *  - declare a ring and two polynomials f and g; then type <c>system("c++wrappers", f, g);</c>
     38 *    to perform <c>wrapSINGULARPolys</c> (see file Wrappers.h).
     39 */
     40
     41/*! type definition for the type of the instance counter inside the class ReferenceCounter */
     42typedef unsigned long ReferenceCounterType;
     43
     44/*! type definition for SINGULAR-internal polynomials */
     45typedef poly SingularPoly;
     46
     47/*! type definition for SINGULAR-internal rings */
     48typedef ring SingularRing;
     49
     50/*!
     51 *  A method for performing a series of tests with the wrapper code.<br>
     52 *  More concretely, the following tests will be performed:<br>
     53 *  - Test0: Creation of RingWrapper from current SINGULAR ring, if any,<br>
     54 *  - Test1: Creation and destruction of instances of RingWrapper,<br>
     55 *  - Test2: Creation, copying, assignment, and destruction of instances of PolyWrapper,<br>
     56 *  - Test3: Addition of compatible instances of PolyWrapper,<br>
     57 *  - Test4: Addition of incompatible instances of PolyWrapper.<br>
     58 *
     59 *  After compiling SINGULAR and including the line<br>
     60 *  <c>#define HAVE_WRAPPERS 1</c><br>
     61 *  in <c>/SINGULAR/mod2.h</c> and in <c>/kernel/mod2.h</c>, the user may call this
     62 *  method by typing <c>system("c++wrappers", 0)</c> (without detailed console printout),
     63 *  or <c>system("c++wrappers", 1)</c> (with detailed console printout).
     64 *  @param detailedOutput if true this enforces a very detailed console output including internal method calls etc.
     65 */
    1066void testWrappers (bool detailedOutput);
    1167
    12 typedef poly SingularPoly;
    13 typedef ring SingularRing;
     68/*!
     69 *  A method for wrapping SINGULAR-internal polynomials as instances of PolyWrapper
     70 *  and afterwards computing their sum as an instance of PolyWrapper.<br>
     71 *  After compiling SINGULAR and including the line<br>
     72 *  <c>#define HAVE_WRAPPERS 1</c><br>
     73 *  in <c>/SINGULAR/mod2.h</c> and in <c>/kernel/mod2.h</c>, the user may call this
     74 *  method by first declaring two polys f and g, and typing
     75 *  <c>system("c++wrappers", f, g)</c>.
     76 *  @param sp1 a SINGULAR-internal poly
     77 *  @param sp2 a SINGULAR-internal poly
     78 */
     79void wrapSINGULARPolys (const SingularPoly& sp1, const SingularPoly& sp2);
    1480
    15 extern PrettyPrinter prpr;   // for pretty printing
     81/*! PrettyPrinter used throughout all wrapper code
     82    for pretty-printing detailed output to the console
     83    if requested */
     84extern PrettyPrinter prpr;
    1685
    17 // some enums used for test prior
    18 // to static casts; see code
    19 #define UNSPECIFIED_POLY_TYPE 0
    20 #define CANONICAL_POLY_TYPE 1
    21 
    22 #endif // HAVE_WRAPPERS
     86#endif
     87/* HAVE_WRAPPERS */
    2388
    2489#endif
  • Singular/extra.cc

    rbb503c7 ra388ae  
    22*  Computer Algebra System SINGULAR      *
    33*****************************************/
    4 /* $Id: extra.cc,v 1.326 2009-10-20 10:39:17 monerjan Exp $ */
     4/* $Id: extra.cc,v 1.327 2009-10-21 15:36:00 seelisch Exp $ */
    55/*
    66* ABSTRACT: general interface to internals of Singular ("system" command)
     
    21062106      if(strcmp(sys_cmd,"c++wrappers")==0)
    21072107      {
    2108         if (h == NULL) testWrappers(FALSE);  // wrapper tests, no detailed printout
     2108        if (h == NULL) testWrappers(FALSE);  /* wrapper tests, without detailed printout */
    21092109        else if (h->Typ() == INT_CMD)
    21102110        {
    21112111          const int detailedOutput = (const int)(long)h->Data();
    21122112          testWrappers(detailedOutput == 0 ? FALSE : TRUE);
    2113           // wrapper tests, with or without detailed printout
     2113          /* wrapper tests, with or without detailed printout */
     2114        }
     2115        else if ((h->Typ() == POLY_CMD) &&
     2116                 (h->next->Typ() == POLY_CMD))
     2117        {
     2118          const poly& p1 = (const poly)h->Data();
     2119          const poly& p2 = (const poly)h->next->Data();
     2120          wrapSINGULARPolys(p1, p2);
     2121          /* wraps the given polys (as elements of the current ring)
     2122             and displays the created instances of PolyWrapper, then
     2123             their sum is computed as an instance of PolyWrapper and
     2124             also displayed */
    21142125        }
    21152126        return FALSE;
    21162127      }
    21172128      else
    2118 #endif // HAVE_WRAPPERS
     2129#endif
     2130/* HAVE_WRAPPERS */
    21192131/*==================== new minor code ========================*/
    21202132#ifdef HAVE_MINOR
    21212133      if(strcmp(sys_cmd,"minors")==0)
    21222134      {
    2123         if (h == NULL) minorUsageInfo();  // writes some info to the console
    2124                                           // on how to use this experimental code
     2135        if (h == NULL) minorUsageInfo();  /* writes some info to the console
     2136                                             on how to use this experimental code */
    21252137        else if (h->Typ() == INT_CMD)
    21262138        {
    2127            testIntMinors(0);  // effectively no arguments provided:
    2128                               // this starts 5 default tests
    2129                               // with a random matrix with
    2130                               // integer entries;
    2131                               // for that, no ring needs to be
    2132                               // declared
     2139           testIntMinors(0);  /* no arguments provided:
     2140                                this starts 5 default tests
     2141                                with a random matrix with
     2142                                integer entries;
     2143                                for that, no ring needs to be
     2144                                 declared beforehand */
    21332145        }
    21342146        else if ((h->Typ() == MATRIX_CMD) &&
     
    21452157          const int cacheWeight    = (const int)(long)h->next->next->next->next->Data();
    21462158          ideal iii = testAllPolyMinorsAsIdeal(m, k, strategy, cacheEntries, cacheWeight);
    2147             // starts the computation of all k x k minors in the
    2148             // provided matrix m (which is assumed to have polynomial
    2149             // entries);
    2150             // when calling this method, a ring must be declared before;
    2151             // there will be one run using a cache with specified properties
     2159            /* starts the computation of all (k x k)-minors in the
     2160              provided matrix m (which is assumed to have polynomial
     2161              entries);
     2162               when calling this method, a ring must have been declared before;
     2163               there will be one run using a cache with specified properties */
    21522164          res->rtyp = IDEAL_CMD;
    21532165          res->data = iii;
     
    21682180          const int characteristic = (const int)(long)h->next->next->next->next->next->Data();
    21692181          ideal iii = testAllIntMinorsAsIdeal(m, k, strategy, cacheEntries, cacheWeight, characteristic);
    2170             // starts the computation of all k x k minors in the
    2171             // provided matrix m (which is assumed to have integer
    2172             // entries);
    2173             // when calling this method, a ring must be declared before;
    2174             // there will be one run using a cache with specified properties;
    2175             // the resulting minors will be computed modulo the given characteristic
     2182            /* starts the computation of all (k x k)-minors in the
     2183              provided matrix m (which is assumed to have integer
     2184              entries);
     2185               when calling this method, a ring must have been declared before;
     2186              there will be one run using a cache with specified properties;
     2187               the resulting minors will be computed modulo the given characteristic */
    21762188          res->rtyp = IDEAL_CMD;
    21772189          res->data = iii;
     
    21972209          const int dumpConsole    = (const int)(long)h->next->next->next->next->next->next->next->next->Data();
    21982210          testAllPolyMinors(m, k, strategies, cacheEntries, cacheWeight, dumpMinors, dumpResults, dumpComplete, dumpConsole);
    2199             // starts the computation of all k x k minors in the
    2200             // provided matrix m (which is assumed to have polynomial
    2201             // entries) using a cache with a maximum number of
    2202             // 'cacheEntries' entries and a maximum weight of 'cacheWeight';
    2203             // when calling this method, a ring must be declared before;
    2204             // strategy = "310" means that the code is run first without a
    2205             // cache ("0") and then afterwards with the caching strategies
    2206             // "1" and "3"
     2211            /* starts the computation of all (k x k)-minors in the
     2212               provided matrix m (which is assumed to have polynomial
     2213               entries) using a cache with a maximum number of
     2214               'cacheEntries' entries and a maximum weight of 'cacheWeight'
     2215               (The weight is the number of cached monomials, counted over
     2216               all cached polynomials.);
     2217               when calling this method, a ring must have been declared before;
     2218               strategy = "310" means that the code is run first without a
     2219               cache ("0") and then afterwards with the caching strategies
     2220               "1" and "3" */
    22072221        }
    22082222        else if (h->Typ() == POLY_CMD)
    2209         { // for quick tests with a single polynomial
     2223        { /* for quick tests with a single polynomial */
    22102224          const poly p = (const poly)h->Data();
    22112225          testStuff(p);
     
    22222236          const int varN   = (const int)(long)h->next->Data();
    22232237          {
    2224             /*
    2225             The following code creates and returns a ring with characteristic fc,
    2226             order dp and varN variables with the names "x1", "x2", ..., "x4711"
    2227             (in the case varN = 4711).
    2228             The purpose of this rewriting is to eliminate indexed variables,
    2229             as they may cause problems when generating scripts for Magma,
    2230             Maple, or Macaulay2.
    2231             */
     2238            /* The following code creates and returns a ring with characteristic fc,
     2239               order dp and varN variables with the names "x1", "x2", ..., "x4711"
     2240               (in the case varN = 4711).
     2241               The purpose of this rewriting is to eliminate indexed variables,
     2242               as they may cause problems when generating scripts for Magma,
     2243               Maple, or Macaulay2. */
    22322244            ring newRing = (ring) omAlloc0Bin(sip_sring_bin);
    22332245            newRing->ch = fc;
     
    22572269      }
    22582270      else
    2259 #endif // HAVE_MINOR
     2271#endif
     2272/* HAVE_MINOR */
    22602273/*==================== generic debug ==================================*/
    22612274#ifdef PDEBUG
     
    34503463    extern BOOLEAN Main(leftv res, leftv h); // FALSE = Ok, TRUE = Error!
    34513464    return Main(res, h);
    3452   }
     3465  }                           
    34533466  else
    34543467#endif // HAVE_SINGULAR_PLUS_PLUS
     
    34673480if (strcmp(sys_cmd,"gfan")==0)
    34683481{
    3469 //         if ((h==NULL) || (h!=NULL && h->Typ()!=IDEAL_CMD))
    3470 //         {
    3471 //                 Werror("system(\"gfan\"...) Ideal expected");
    3472 //                 return TRUE; //Ooooops
    3473 //         }
    3474 //      else if(h->next==NULL)
    3475 //      {
    3476 //              Werror("gfan expects an integer parameter");
    3477 //              return TRUE;
    3478 //      }
    3479 //      else if(h->next!=NULL && h->next->Typ()!=INT_CMD)
    3480 //      {
    3481 //              Werror("1st parameter ist no integer");
    3482 //              return TRUE;
    3483 //      }
    3484         /*
    3485         heuristic:
    3486         0 = keep all Gröbner bases in memory
    3487         1 = write all Gröbner bases to disk and read whenever necessary
    3488         2 = use a mixed heuristic, based on length of Gröbner bases
    3489         */
    3490         if( h!=NULL && h->Typ()==IDEAL_CMD && h->next!=NULL && h->next->Typ()==INT_CMD)
    3491         {
    3492                 int heuristic;
    3493                 heuristic=(int)(long)h->next->Data();
    3494                 ideal I=((ideal)h->Data());
    3495                 res->rtyp=IDEAL_CMD;
    3496                 res->data=(ideal) gfan(I,heuristic);
    3497                 return FALSE;
    3498         }
    3499         else
    3500         {
    3501                 WerrorS("Usage: system(\"gfan\",I,int)");
    3502                 return TRUE;
    3503         }
     3482        if ((h==NULL) || (h!=NULL && h->Typ()!=IDEAL_CMD))
     3483        {
     3484                Werror("system(\"gfan\"...) Ideal expected");
     3485                return TRUE; //Ooooops
     3486        }
     3487ideal I=((ideal)h->Data());
     3488res->rtyp=IDEAL_CMD;
     3489res->data=(ideal) gfan(I);
    35043490//res->rtyp=LIST_CMD;
    35053491//res->data= ???
    35063492
    3507 // return FALSE; //Everything went fine
     3493return FALSE; //Everything went fine
    35083494}
    35093495else
Note: See TracChangeset for help on using the changeset viewer.