From 13ba6be77500f685aaecab9e6313e5d9e8cbe744 Mon Sep 17 00:00:00 2001 From: Cotton Seed Date: Sat, 28 Jul 2012 13:48:17 -0400 Subject: [PATCH] Fixed a few bugs coming from the rebase of square to master: initialize impl in set_wrapper, missing operator != on linear_combination, some reader/writer problems related to writing algebra. --- algebra/linear_combination.h | 1 + lib/io.cpp | 22 +++++++++++++ lib/io.h | 11 ++++--- lib/set_wrapper.h | 1 + main.cpp | 64 +++++++++++++++++++++--------------- sseq.h | 2 ++ todo.txt | 1 + 7 files changed, 72 insertions(+), 30 deletions(-) diff --git a/algebra/linear_combination.h b/algebra/linear_combination.h index c8b0604..373a0b8 100644 --- a/algebra/linear_combination.h +++ b/algebra/linear_combination.h @@ -366,6 +366,7 @@ class linear_combination } bool operator == (const linear_combination &lc) const { assert (m == lc.m); return v == lc.v; } + bool operator != (const linear_combination &lc) const { return !operator == (lc); } bool operator == (int x) const { assert (x == 0); return v.is_empty (); } bool operator != (int x) const { return !operator == (x); } diff --git a/lib/io.cpp b/lib/io.cpp index d1bb53e..c6a75fc 100644 --- a/lib/io.cpp +++ b/lib/io.cpp @@ -2,6 +2,17 @@ // #include #include +writer::writer (bool raw_) + : raw(raw_), + aw(new algebra_writer) +{ +} + +writer::~writer () +{ + delete aw; +} + void writer::write_int (int x) { @@ -111,6 +122,17 @@ writer::write_mpz (const mpz_t x) free (buf); } +reader::reader (bool raw_) + : raw(raw_), + ar(new algebra_reader) +{ +} + +reader::~reader () +{ + delete ar; +} + int reader::read_int () { diff --git a/lib/io.h b/lib/io.h index b995fde..1860c28 100644 --- a/lib/io.h +++ b/lib/io.h @@ -12,8 +12,8 @@ class writer public: writer (const writer &) = delete; - writer (bool raw_ = false) : raw(raw_), aw(0) { } - virtual ~writer () = default; + writer (bool raw_); + virtual ~writer (); writer &operator = (const writer &) = delete; @@ -26,6 +26,8 @@ class writer void write_unsigned (unsigned x); void write_uint64 (uint64 x); + virtual void write_mpz (const mpz_t x); + template void write_mod (ptr > m); }; @@ -36,8 +38,8 @@ class reader public: reader (const reader &) = delete; - reader (bool raw_) : raw(raw_), ar(0) { } - virtual ~reader () = default; + reader (bool raw_); + virtual ~reader (); reader &operator = (const reader &) = delete; @@ -67,6 +69,7 @@ class reader int read_int (); unsigned read_unsigned (); uint64 read_uint64 (); + virtual void read_mpz (mpz_t x); template ptr > read_mod (); diff --git a/lib/set_wrapper.h b/lib/set_wrapper.h index a31e654..ef8eb04 100644 --- a/lib/set_wrapper.h +++ b/lib/set_wrapper.h @@ -124,6 +124,7 @@ class set_wrapper_const_iter template set_wrapper::set_wrapper (reader &r) + : impl(new set_wrapper_impl) { unsigned n; read (r, n); diff --git a/main.cpp b/main.cpp index 420050d..3a8ca2d 100644 --- a/main.cpp +++ b/main.cpp @@ -269,7 +269,7 @@ load (map, mod_map > > m (r); for (map c (kd); + mod_map d = c.compute_d (1, 0, 0, 0, 0); + + chain_complex_simplifier s (c.khC, d, 1); + + steenrod_square sq (c, d, s); + mod_map sq1 = sq.sq1 (); + mod_map sq2 = sq.sq2 (); + + assert (sq1.compose (sq1) == 0); + assert (sq2.compose (sq2) + sq1.compose (sq2).compose (sq1) == 0); + + display ("sq1:\n", sq1); + display ("sq2:\n", sq2); + + { + file_writer w ("sqtest.dat"); + write (w, sq1); + write (w, sq2); + } + + { + file_reader r ("sqtest.dat"); + mod_map sq1p (r); + mod_map sq2p (r); + display ("sq1p:\n", sq1p); + display ("sq2p:\n", sq2p); + } + +#endif + #if 0 knot_diagram kd (mt_link (10, 0, 9)); cube c (kd); @@ -728,7 +763,7 @@ main () printf ("|knot_kh_sq| = %d\n", knot_kh_sq.card ()); -#if 1 +#if 0 map, map >, pair c (kd); - mod_map d = c.compute_d (1, 0, 0, 0, 0); - - chain_complex_simplifier s (c.khC, d, 1); - - steenrod_square sq (c, d, s); - mod_map sq1 = sq.sq1 (); - mod_map sq2 = sq.sq2 (); - - assert (sq1.compose (sq1) == 0); - assert (sq2.compose (sq2) + sq1.compose (sq2).compose (sq1) == 0); - - display ("sq1:\n", sq1); - display ("sq2:\n", sq2); - - writer w ("sqtest.dat"); - write (w, sq1); - write (w, sq2); -#endif - #if 0 #if 0 reader r ("sqtest.dat"); @@ -1165,6 +1176,7 @@ main () assert (sq1.compose (sq1) == 0); assert (sq2.compose (sq2) + sq1.compose (sq2).compose (sq1) == 0); } +#endif #if 0 typedef Z2 R; diff --git a/sseq.h b/sseq.h index d2f5420..a928cab 100644 --- a/sseq.h +++ b/sseq.h @@ -106,6 +106,7 @@ class sseq void texshow (FILE *fp, std::string name); }; +#if 0 template class simplified_complex_generators { unsigned new_n; @@ -376,6 +377,7 @@ chain_complex_simplifier::chain_complex_simplifier (ptr > C_, #endif } } +#endif class sseq_builder { diff --git a/todo.txt b/todo.txt index 9b28950..ea1c63b 100644 --- a/todo.txt +++ b/todo.txt @@ -40,6 +40,7 @@ general: (e.g. knot_diagram, resolution_diagram, etc.) -- this is the right semantics. - clean up/delete setcommon, mapcommon + - incorporate sage dump into standard classes c++11: - make vector wrap std::vector (probably faster)