Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

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

r""" 

Interface to Groebner Fan 

 

AUTHOR: 

 

- Anders Nedergaard Jensen: Write gfan C++ program, which implements 

algorithms many of which were invented by Jensen, Komei 

Fukuda, and Rekha Thomas. 

- William Stein (2006-03-18): wrote gfan interface (first version) 

- Marshall Hampton (2008-03-17): modified to use gfan-0.3, subprocess instead of os.popen2 

 

TODO -- much functionality of gfan-0.3 is still not exposed:: 

 

* at most 52 variables: 

 

- use gfan_substitute to make easier (?) 

MH: I think this is now irrelevant since gfan can accept the original ring variables 

 

* --symmetry is really useful 

- permutations are 0-based *not* cycle notation; a <---> 0 

output is broken up much more nicely. 

 

* -- can work in Z/pZ for p <= 32749 

 

* -- can compute individual GB's for lex and revlex (via buchberger) 

""" 

 

#***************************************************************************** 

# Copyright (C) 2006 William Stein <wstein@gmail.com> 

# 

# Distributed under the terms of the GNU General Public License (GPL) 

# 

# This code is distributed in the hope that it will be useful, 

# but WITHOUT ANY WARRANTY; without even the implied warranty of 

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 

# General Public License for more details. 

# 

# The full text of the GPL is available at: 

# 

# http://www.gnu.org/licenses/ 

#***************************************************************************** 

from __future__ import print_function 

 

from subprocess import Popen, PIPE 

 

 

class Gfan: 

""" 

Interface to Anders Jensen's Groebner Fan program. 

""" 

def __call__(self, I, cmd='',verbose = False, format=True): 

if cmd != '' and cmd.lstrip()[0] != '-': 

cmd = 'gfan_%s'%cmd 

else: 

cmd = 'gfan' 

 

if len(cmd.split(' ')) > 1: 

cmd = cmd.split(' ') 

 

if verbose: 

print("gfan command:\n%s" % cmd) 

print("gfan input:\n%s" % I) 

 

gfan_processes = Popen(cmd,stdin = PIPE, stdout=PIPE, stderr=PIPE) 

ans, err = gfan_processes.communicate(input = I) 

 

# since version 0.4, gfan indicates which LP algorithm it is using. 

# we avoid interpreting this as an error 

if (len(err) > 0) and not (err.startswith('LP algorithm being used:')): 

raise RuntimeError(err) 

 

return ans 

 

# The instance 

gfan = Gfan()