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

""" 

libSingular: Function Factory 

 

AUTHORS: 

 

- Martin Albrecht (2010-01): initial version 

 

""" 

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

# Copyright (C) 2010 Martin Albrecht <M.R.Albrecht@rhul.ac.uk> 

# 

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

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

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

 

from sage.libs.singular.function import singular_function, lib, list_of_functions 

 

class SingularFunctionFactory(object): 

""" 

A convenient interface to libsingular functions. 

""" 

def __getattr__(self, name): 

""" 

EXAMPLES:: 

 

sage: import sage.libs.singular.function_factory 

sage: groebner = sage.libs.singular.function_factory.ff.groebner 

sage: groebner 

groebner (singular function) 

 

sage: import sage.libs.singular.function_factory 

sage: primdecSY = sage.libs.singular.function_factory.ff.primdec__lib.primdecSY 

sage: primdecSY 

primdecSY (singular function) 

""" 

if name.startswith("_"): 

raise AttributeError("Singular Function Factory has no attribute '%s'"%name) 

 

try: 

return singular_function(name) 

except NameError: 

if name.endswith("__lib"): 

name = name[:-5] 

lib(name+".lib") 

return SingularFunctionFactory() 

else: 

raise NameError("function or package '%s' unknown."%(name)) 

 

def trait_names(self): 

""" 

EXAMPLES:: 

 

sage: import sage.libs.singular.function_factory 

sage: "groebner" in sage.libs.singular.function_factory.ff.trait_names() 

True 

 

""" 

return list_of_functions() 

 

ff = SingularFunctionFactory()