File: checkregularity.cc

package info (click to toggle)
topcom 1.1.2%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 31,784 kB
  • sloc: cpp: 37,616; sh: 4,262; makefile: 497; ansic: 49
file content (126 lines) | stat: -rw-r--r-- 4,341 bytes parent folder | download | duplicates (2)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#include "CommandlineOptions.hh"
#include "PointConfiguration.hh"
#include "Symmetry.hh"
#include "Chirotope.hh"
#include "Incidences.hh"
#include "PlacingTriang.hh"
#include "RegularityCheck.hh"

int main(const int argc, const char** argv) {

  using namespace topcom;
  
  CommandlineOptions::init(argc, argv);
  RegularityCheck::init();

  if (CommandlineOptions::verbose()) {
    std::cerr << std::endl;
    std::cerr << "------------------------------------------------------------\n";
    std::cerr << "------------------ " << PACKAGE << " VERSION " << VERSION << " --------------------\n";
    std::cerr << "Triangulations of Point Configurations and Oriented Matroids\n";
    std::cerr << "--------------------- by Joerg Rambau ----------------------\n";
    std::cerr << "------------------------------------------------------------\n";
    std::cerr << std::endl;
#ifdef STL_CONTAINERS
    std::cerr << "       -- using STL containers for hash tables --" << std::endl;
#endif
#ifdef STL_SYMMETRIES
    std::cerr << "       -- using STL containers for symmetries  --" << std::endl;
#endif
#ifdef STL_FLIPS
    std::cerr << "       --    using STL containers for flips    --" << std::endl;
#endif
#ifdef STL_CHIROTOPE
    std::cerr << "       -- using STL containers for chirotopes  --" << std::endl;
#endif
    std::cerr << std::endl;
  }

  PointConfiguration points;
  if (!points.read(std::cin)) {
    if (CommandlineOptions::verbose()) {
      std::cerr << "error while reading point configuration" << std::endl;
    }
    return 1;
  }
  if (points.rank() < points.rowdim()) {
    std::cerr << "point configuration has " << points.rowdim() << " rows of rank " << points.rank() << std::endl;
    points.transform_to_full_rank();
    std::cerr << "resulting no of rows after transformation: " << points.rank() << std::endl;
    points.pretty_print(std::cerr);
  }
  if (CommandlineOptions::verbose()) {
    std::cerr << "read point configuration with " << points.no()
	      << " points in rank " << points.rank() << std::endl;
  }
  
  SymmetryGroup symmetries(points.no());
  symmetries.read(std::cin);
  Chirotope chiro(points, false);
  SimplicialComplex triang;
  size_type count(0);
  size_type count_nonregs(0);
  if (CommandlineOptions::memopt()) {
    if (CommandlineOptions::verbose()) {
      std::cerr << "no preprocessing of simplex table to save memory" << std::endl;
    }
  }
  else {
    if (CommandlineOptions::verbose()) {
      std::cerr << "preprocessing simplex table up to rank " << points.rank() << " ..." << std::endl;
    }
    SimplicialComplex::preprocess_index_table(points.no(), 0, points.rank(), chiro, true);
    if (CommandlineOptions::verbose()) {
      std::cerr << "... done." << std::endl;
    }
  }
  if (CommandlineOptions::verbose()) {
    std::cerr << "computing cocircuits ..." << std::endl;
  }
  Cocircuits cocircuits(chiro);
  if (CommandlineOptions::verbose()) {
    std::cerr << "... done." << std::endl;
  }
  if (CommandlineOptions::verbose()) {
    std::cerr << "computing facets ..." << std::endl;
  }
  Facets facets(cocircuits);
  if (CommandlineOptions::verbose()) {
    std::cerr << "... done." << std::endl;
  }
  if (CommandlineOptions::verbose()) {
    std::cerr << "computing incidences ..." << std::endl;
  }
  Incidences incidences(chiro, facets);
  if (CommandlineOptions::verbose()) {
    std::cerr << "... done." << std::endl;
  }
  if (CommandlineOptions::verbose()) {
    std::cerr << "checking input triangulations for regularity ..." << std::endl;
  }
  while (triang.read(std::cin)) {
    ++count;
    RegularityCheck regcheck(points, chiro, incidences, triang);
    if (!regcheck.is_regular()) {
      ++count_nonregs;
      std::cout << "T[" << count << "] := " << triang << " is non-regular." << std::endl;
    }
    else {
      std::cout << "T[" << count << "] := " << triang << " is regular." << std::endl;
      if (CommandlineOptions::output_heights()) {
	std::cout << "h[" << count
		  << "] := " << regcheck.heights() << ";\n";
      }
    }
    std::cerr << "checked " << count << " triangulations, " 
	      << count_nonregs << " non-regular so far." << std::endl;
  }
  if (CommandlineOptions::verbose()) {
    std::cerr << "... no more triangulations found." << std::endl;
  }
  RegularityCheck::term();
  return 0;
}


// eof checkregularity.cc