Macaulay2 Engine
Loading...
Searching...
No Matches
betti.hpp
Go to the documentation of this file.
1// Copyright 2014 Michael E. Stillman.
2
3#ifndef _betti_hpp_
4#define _betti_hpp_
5
36
37#include "buffer.hpp"
38
39#include "memtailor.h"
40#include <unordered_set>
41#include <unordered_map>
42#include <utility>
43
60{
61 public:
62 BettiDisplay(); // sets everything to 0
63 BettiDisplay(int lodegree,
64 int hidegree,
65 int hilen); // initializes to all zero entries
66 BettiDisplay(const BettiDisplay& B); // copy values.
69 void swap(BettiDisplay& B);
70 int& entry(int deg, int lev); // use this to modify the value
71
72 M2_arrayint getBetti() const;
73 void displayBetti(buffer& o) const;
74 void output() const;
75
76 void resize(int new_lo_degree, int new_hi_degree, int new_length);
77 // The following three functions are the given bounds
78 // The actual bounds where there is a non-zero entry are possibly smaller
79 int loDegree() const { return mLoDegree; }
80 int hiDegree() const { return mHiDegree; }
81 int length() const { return mHiLength; }
82 private:
83 // These two functions were in comp-res.cpp, that code was liftd directly to
84 // here.
85 static M2_arrayint betti_make(int lo, int hi, int len, int* bettis);
86 static void betti_display(buffer& o, M2_arrayint ar);
87
92 int* mValues;
93};
94
108{
109public:
110 using value = std::pair<const int*, int>;
111
112 // hash function
113 std::size_t operator()(value m) const
114 {
115 return reinterpret_cast<std::size_t>(const_cast<int*>(m.first)) + 13*m.second;
116 }
117
118 // equality function
119 bool operator() (value a, value b) const
120 {
121 return a == b;
122 }
123};
124
125#endif
126
127// Local Variables:
128// compile-command: "make -C $M2BUILDDIR/Macaulay2/e "
129// indent-tabs-mode: nil
130// End:
Append-only GC-backed byte buffer used throughout the engine for text output.
int hiDegree() const
Definition betti.hpp:80
M2_arrayint getBetti() const
Definition betti.cpp:82
void output() const
Definition betti.cpp:93
int loDegree() const
Definition betti.hpp:79
~BettiDisplay()
Definition betti.cpp:52
int length() const
Definition betti.hpp:81
int mHiDegree
Definition betti.hpp:89
void resize(int new_lo_degree, int new_hi_degree, int new_length)
Definition betti.cpp:58
BettiDisplay()
Definition betti.cpp:5
int * mValues
Definition betti.hpp:92
BettiDisplay & operator=(const BettiDisplay &B)
Definition betti.cpp:42
void displayBetti(buffer &o) const
Definition betti.cpp:87
int mLoDegree
Definition betti.hpp:88
int & entry(int deg, int lev)
Definition betti.cpp:71
int mHiLength
Definition betti.hpp:90
static void betti_display(buffer &o, M2_arrayint ar)
Definition betti.cpp:147
int mNLevels
Definition betti.hpp:91
static M2_arrayint betti_make(int lo, int hi, int len, int *bettis)
Definition betti.cpp:100
std::size_t operator()(value m) const
Definition betti.hpp:113
std::pair< const int *, int > value
Definition betti.hpp:110
Combined hash + equality functor for (int*, int) pairs, used by the resolution code to key an unorder...
Definition betti.hpp:108
#define swap(a, b, t)
Definition monsort.hpp:127