File: monomial.hpp

package info (click to toggle)
macaulay2 1.21%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 133,096 kB
  • sloc: cpp: 110,377; ansic: 16,306; javascript: 4,193; makefile: 3,821; sh: 3,580; lisp: 764; yacc: 590; xml: 177; python: 140; perl: 114; lex: 65; awk: 3
file content (67 lines) | stat: -rw-r--r-- 1,773 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// (c) 1994 Michael E. Stillman

#ifndef _monomial_hh_
#define _monomial_hh_

#include "hash.hpp"
#include "engine-includes.hpp"
#include "buffer.hpp"
#include "varpower.hpp"

#include <vector>

class Monomial : public EngineObject
{
  // The format of a monomial is from varpower.hpp:
  // [2n+1, v1, e1, ..., vn, en]
  intarray val;

  Monomial();
  Monomial(int v, int e);
  Monomial(const int *vp);
  Monomial(M2_arrayint a);

  Monomial(const std::vector<int>& vp);
  
  int * ints() { return val.raw(); }
protected:
  virtual unsigned int computeHashValue() const;

 public:
  static Monomial *make(int v, int e);
  static Monomial *make(M2_arrayint m);
  static Monomial *make(const int *vp);

  // format for this is that of a 'varpower' monomial:
  // [2n+1, v1, e1, v2, e2, ..., vn, en]
  // with each ei != 0.
  static Monomial * make(const std::vector<int>& monom);
  
  const int * ints() const { return val.raw(); }

  Monomial *operator*(const Monomial &b) const;
  Monomial *operator/(const Monomial &b) const;
  Monomial *power(int n) const;
  void monsyz(const Monomial &b, Monomial *&sa, Monomial *&sb) const;
  Monomial *lcm(const Monomial &b) const;
  Monomial *gcd(const Monomial &b) const;

  Monomial *radical() const;
  Monomial *erase(const Monomial &b) const;

  bool is_one() const;
  bool is_equal(const Monomial &b) const;
  bool divides(const Monoid *M, const Monomial &b) const;
  int compare(const Monoid *M, const Monomial &b) const;
  int simple_degree() const;

  void text_out(buffer &o) const { varpower::elem_text_out(o, val.raw()); }
  M2_arrayint to_arrayint() const { return varpower::to_arrayint(val.raw()); }
};

#endif

// Local Variables:
// compile-command: "make -C $M2BUILDDIR/Macaulay2/e "
// indent-tabs-mode: nil
// End: