knotkit/algebra/grading.h
Cotton Seed 417fe1ea4d Added io support for module, linear_combination, mod_map and grading.
Added intersection and sum for free_submodule.  Modified mpimain to
dump cohomology, sq1 and sq2 as objects (instead of poincare series).
2012-07-28 13:26:30 -04:00

64 lines
1.2 KiB
C++

class grading
{
public:
int h, q;
public:
grading () : h(0), q(0) { }
grading (int h_, int q_) : h(h_), q(q_) { }
grading (const grading &gr) : h(gr.h), q(gr.q) { }
grading (reader &r)
{
h = r.read_int ();
q = r.read_int ();
}
~grading () { }
grading &operator = (const grading &gr) { h = gr.h; q = gr.q; return *this; }
grading operator + (const grading &gr) const
{
return grading (h + gr.h, q + gr.q);
}
grading operator - (const grading &gr) const
{
return grading (h - gr.h, q - gr.q);
}
grading &operator += (const grading &gr)
{
h += gr.h;
q += gr.q;
return *this;
}
grading &operator -= (const grading &gr)
{
h -= gr.h;
q -= gr.q;
return *this;
}
bool operator == (const grading &gr) const { return h == gr.h && q == gr.q; }
bool operator != (const grading &gr) const { return !operator == (gr); }
bool operator < (const grading &gr) const
{
return h < gr.h
|| (h == gr.h && q < gr.q);
}
grading mirror_grading (unsigned nplus, unsigned nminus, bool torsion) const;
void write_self (writer &w) const
{
w.write_int (h);
w.write_int (q);
}
void show_self () const;
void display_self () const;
};