diff --git a/apps/fan/src/common_refinement.cc b/apps/fan/src/common_refinement.cc index 1e4a130..d436991 100644 --- a/apps/fan/src/common_refinement.cc +++ b/apps/fan/src/common_refinement.cc @@ -24,6 +24,30 @@ namespace polymake { namespace fan { +template +Array construct_cones(const Array > & max_cones, const Matrix & rays, const Matrix & lin_space){ + perl::ObjectType cone_type=perl::ObjectType::construct("Cone"); + + int size = lin_space.rows() > 0 ? max_cones.size()+1 : max_cones.size(); + + Array all_cones(size); + for (int i=0; i cone_vert=rays.minor(max_cones[i],All); + all_cones[i].take("RAYS")< 0) { + all_cones[max_cones.size()].create_new(cone_type); + const Matrix ns = null_space(lin_space); + all_cones[max_cones.size()].take("INEQUALITIES")<< ns/(-ns); + } + + return all_cones; +} + template perl::Object common_refinement(perl::Object f1, perl::Object f2) { @@ -32,8 +56,8 @@ perl::Object common_refinement(perl::Object f1, perl::Object f2) Matrix rays1=f1.give("RAYS"); const Matrix lineality_space1=f1.give("LINEALITY_SPACE"); const Matrix lineality_space2=f2.give("LINEALITY_SPACE"); - const Matrix lineality_space = - null_space(null_space(lineality_space1) / null_space(lineality_space2)); + const Matrix lineality_space = (lineality_space1.cols() > 0 && lineality_space2.cols() > 0)? + null_space(null_space(lineality_space1) / null_space(lineality_space2)) : Matrix() ; const Array > max_cones2=f2.give("MAXIMAL_CONES"); Matrix rays2=f2.give("RAYS"); const bool complete = f1.give("COMPLETE") && f2.give("COMPLETE"); @@ -57,22 +81,8 @@ perl::Object common_refinement(perl::Object f1, perl::Object f2) } */ std::list > new_max_cones; - perl::ObjectType cone_type=perl::ObjectType::construct("Cone"); - - Array all_cones1(max_cones1.size()); - for (int i=0; i p1_cone_vert=rays1.minor(max_cones1[i],All); - all_cones1[i].take("RAYS")< all_cones2(max_cones2.size()); - for (int i=0; i p2_cone_vert=rays2.minor(max_cones2[i],All); - all_cones2[i].take("RAYS")< all_cones1 = construct_cones(max_cones1, rays1, lineality_space1); + Array all_cones2 = construct_cones(max_cones2, rays2, lineality_space2); for (Entire >::iterator i1=entire(all_cones1); !i1.at_end(); ++i1) { for (Entire >::iterator i2=entire(all_cones2); !i2.at_end(); ++i2) { @@ -98,7 +108,7 @@ perl::Object common_refinement(perl::Object f1, perl::Object f2) Set new_cone; for (Entire::const_iterator j=entire(sequence(0,index)); !j.at_end(); ++j) if (ray_indices[*j]>=0) new_cone.insert(ray_indices[*j]); - new_max_cones.push_back(new_cone); + if (new_cone.size() > 0) new_max_cones.push_back(new_cone); } } }