23 #include <boost/math/special_functions/factorials.hpp>
45 {
for (
unsigned int j=0; j<iteGN.
current()->numberOfFacets(); j++) {
62 {
for (
unsigned int j=0; j<iteGN.
current()->numberOfFacets(); j++) {
63 unsigned int facetNumber = P->getHalfSpaceNumber( iteGN.
current()->getFacet(j) );
83 std::stack< PolytopeToSimplexes > stackOfPolToSimp;
84 std::vector< unsigned int > listOfVtx;
86 for (
unsigned int i=0; i<
_polytope->numberOfGenerators(); ++i)
87 listOfVtx.push_back(i);
89 stackOfPolToSimp.push(P2S);
91 while (stackOfPolToSimp.size() != 0) {
93 unsigned int shift =
_dimension-stackOfPolToSimp.top().dimension();
94 std::cout <<
"The top of the stack is:" << std::endl;
95 stackOfPolToSimp.top().dump(std::cout, shift);
100 std::cout <<
"[*** The current polytope is a simplex ***]" << std::endl;
109 std::cout <<
"After switchToFullDimension():" << std::endl;
110 stackOfPolToSimp.top().dump(std::cout, shift);
112 stackOfPolToSimp.pop();
119 std::cout <<
"[*** The current polytope is to be split ***]" << std::endl;
124 unsigned int apexNumber = vtx2plit[0];
125 std::vector< unsigned int >::const_iterator itEnd = vtx2plit.end();
126 std::vector< unsigned int >::const_iterator itBeg = vtx2plit.begin();
129 std::vector< unsigned int > newVtx;
130 newVtx.insert(newVtx.begin(), itBeg, itEnd);
133 stackOfPolToSimp.pop();
135 {
for (
unsigned int facetNumber=0; facetNumber<
_numberOfFacets; ++facetNumber) {
138 std::cout <<
"Search " << facetNumber <<
" in : ";
140 std::cout << std::endl;
146 std::cout <<
"Not found facet number : " << facetNumber << std::endl;
150 std::vector< unsigned int > verticesOnGivenFacet;
151 std::set_intersection(
156 std::inserter( verticesOnGivenFacet, verticesOnGivenFacet.begin() ) );
157 if (verticesOnGivenFacet.size() >= topOfStack_cp.
dimension()) {
159 stackOfPolToSimp.push(newP2S);
162 std::copy(newVtx.begin(), newVtx.end(), std::ostream_iterator<unsigned int>(std::cout,
" "));
163 std::cout <<
"} INTER { ";
165 std::cout <<
"}" << std::endl;
167 std::cout <<
"{" << newP2S.
dimension() <<
":";
169 std::cout << std::endl;
172 std::cout <<
"}" << std::endl;
182 std::cout <<
"_allSimplices : " << std::endl;
184 std::cout <<
"{" << it->dimension() <<
":";
185 std::copy(it->getListOfProcessedVertices().begin(), it->getListOfProcessedVertices().end(), std::ostream_iterator<unsigned int>(std::cout,
" "));
186 std::cout << std::endl;
187 std::copy(it->getListOfVerticesToSplit().begin(), it->getListOfVerticesToSplit().end(), std::ostream_iterator<unsigned int>(std::cout,
" "));
188 std::cout <<
"}" << std::endl;
189 std::cout << std::endl;
197 std::cout <<
"VolumeOfPolytopes_Rn::volume() : " <<
_allSimplices.size() << std::endl;
199 std::set< std::set< boost::shared_ptr<Generator_Rn> > > listOfCoordSimplices;
200 std::vector< PolytopeToSimplexes >::iterator it1;
203 std::set< boost::shared_ptr<Generator_Rn> > setOfGN;
204 std::vector< unsigned int >::const_iterator it2;
206 std::cout <<
"Current simplex : ";
207 std::copy(it1->getListOfProcessedVertices().begin(), it1->getListOfProcessedVertices().end(), std::ostream_iterator<unsigned int>(std::cout,
" "));
208 std::cout << std::endl;
210 {
for (it2=it1->getListOfProcessedVertices().begin(); it2!=it1->getListOfProcessedVertices().end(); ++it2) {
211 setOfGN.insert(
_polytope->getGenerator( *it2 ));
213 listOfCoordSimplices. insert(setOfGN);
217 std::set< std::set< boost::shared_ptr<Generator_Rn> > >::const_iterator constITER_setGN;
218 {
for (constITER_setGN=listOfCoordSimplices.begin(); constITER_setGN!=listOfCoordSimplices.end(); ++constITER_setGN) {
221 std::cout <<
"volumeOfSimplex=" << current_volume << std::endl;
231 boost::shared_ptr<Generator_Rn> vx0 = *(listOfSimplexVertices.begin());
232 boost::numeric::ublas::matrix<double> mat2computeDET(RnDIM, RnDIM);
233 std::set< boost::shared_ptr<Generator_Rn> >::const_iterator constITER_GN = listOfSimplexVertices.begin();
236 {
for ( ; constITER_GN!=listOfSimplexVertices.end(); ++constITER_GN) {
237 for (
unsigned int j=0; j<mat2computeDET.size2(); ++j)
238 mat2computeDET(i,j) = (*constITER_GN)->getCoordinate(j) - vx0->getCoordinate(j);
242 std::cout <<
"mat2computeDET=" << mat2computeDET << std::endl;
250 unsigned int i,j,j1,j2;
251 unsigned int n = mat.size1();
259 det = mat(0,0)*mat(1,1) - mat(1,0)*mat(0,1);
263 for (j1=0; j1<n; j1++) {
264 boost::numeric::ublas::matrix<double> smaller_mat(n-1, n-1);
265 for (i=1; i<n; i++) {
267 for (j=0; j<n; j++) {
270 smaller_mat(i-1,j2) = mat(i,j);