Page 1 of 1

check faces in simplicial complexes

Posted: 19 Feb 2011, 17:01
by emerson
Hi. I wanted to ask what is the right way to check if some set is a face in a simplicial complex. Up to now, I do it by getting errors using some commands (e.g. star), but if the computer can detect this error, probably there is a command to check this. Regards...

Re: check faces in simplicial complexes

Posted: 19 Feb 2011, 18:50
by joswig
Well, you should write a short loop and check that set for containment in all facets.

Re: check faces in simplicial complexes

Posted: 19 Feb 2011, 23:45
by gawrilow
If you are going to repeatedly look for faces in the same simplicial complex, you would save quite some time if you load the complex' facets into a FacetList object once and then query for face containment using its method findMax. For a one-off query, however, a simple loop as suggested by Michael will be a more appropriate solution.

Re: check faces in simplicial complexes

Posted: 24 Feb 2011, 14:35
by emerson
Thanks... Unfortunately this answer causes me many other questions... First of all, I wanted to ask if there is an easy method to detect and control errors in the program. Something like an 'if(error){}' command, to display something and then continue, as nothing happened.
I also don't know how to check for two sets if one is subset of the other... I was trying to play with the command 'incl' that seems to work, but gives me funny answers when I'm expecting a simple boolean value. I guess I can also do a loop and check if each element belongs to the set, but I also don't know how to check that. Maybe some links to relevant documentation of the common objects can be helpful.
The thing is that polymake can already do this very well, with methods from the complex-properties.rules... I just don't want to code again the wheel. Unfortunately I don't have much experience yet with c++ clients, but I hope this change soon. By the way, I'm planning to attend this polymake workshop, but better to get used with all this issues before that, in order to understand something there... Regards...

Re: check faces in simplicial complexes

Posted: 24 Feb 2011, 18:15
by gawrilow
First of all, I wanted to ask if there is an easy method to detect and control errors in the program. Something like an 'if(error){}' command, to display something and then continue, as nothing happened.
polymake extensively uses exceptions for reporting errors. How you catch them depends on the context.

In a C++ client, you enclose the potentially dangerous code in a try { ... } block and catch std::exception after it. All exception types used in polymake are derived from this type.

In a perl script, you enclose the dangerous code in eval { ... } and check the variable $@ after it; it will contain the error message or will be empty if nothing nasty happened. See also topics `die' and `eval' in `man perlfunc'.
I also don't know how to check for two sets if one is subset of the other... I was trying to play with the command 'incl' that seems to work, but gives me funny answers when I'm expecting a simple boolean value.
incl(s1, s2) returns -1 if s1 is included in s2, 0 if both sets are equal, 1 if s2 is included in s1, and, finally, 2 in all other cases. Except for the special last value, its behavior exactly resembles the three-way comparison operator <=> .
I can also do a loop and check if each element belongs to the set, but I also don't know how to check that.
In C++: s.exists(elem)

In perl: exists $s->{$elem} or $s->contains($elem)
Both do the same, first expression looking more "perly".