Ask Your Question

BWW's profile - activity

2018-06-17 20:37:15 -0500 received badge  Notable Question (source)
2016-05-10 16:47:21 -0500 received badge  Notable Question (source)
2015-09-09 18:33:30 -0500 received badge  Popular Question (source)
2015-01-14 03:27:41 -0500 received badge  Taxonomist
2012-09-10 20:47:57 -0500 received badge  Popular Question (source)
2011-06-29 08:36:52 -0500 commented answer Working with sage graphics

I apologise for misleading you. I have done what you suggest. I have also written the code for plotting ribbon graphs. It works. For an individual ribbon graph it is slow. For a linear combination graphics_array works but is not really satisfactory. I have not tracked down the code for graph plotting.

2011-06-29 07:07:06 -0500 commented answer Working with sage graphics

I was asked to produce a toy example. Maybe I did not choose a good example.

2011-06-29 04:44:08 -0500 commented answer Working with sage graphics

I am aware of list comprehension. I don't see how this helps.

2011-06-29 04:41:32 -0500 commented answer Working with sage graphics

I am not explaining myself very well. I am implementing the mathematical notion of a ribbon graph. There is some overlap in the functionality with abstract graphs. I might learn something from the code for the sage Graph class but I can't just call the functions.

2011-06-28 22:53:41 -0500 commented question Working with sage graphics

Which graph plotting procedures are you referring to?

2011-06-28 21:38:55 -0500 received badge  Supporter (source)
2011-06-28 01:02:28 -0500 asked a question Working with sage graphics

I have written some code to plot some graphs (that is vertices and edges) and it has been suggested that I am being inefficient. I have say 50-100 primitives (consisting of lines and circles). At the moment I use to Graphics() to create an empty graphics object and then use + to add the primitives. Is there a better way to do this?

Edit The add_primitive() is one improvement. Here is a toy example

n = 10
g = Graphics()
for i in range(n):
    for j in range(n):
        g += line([(i,j),(i+1,j)])
        g += line([(i,j),(i,j+1)])

n = 10
g = Graphics()
for i in range(n):
    for j in range(n):

A second question is that I would also like to plot a formal linear combination of these graphs. At the moment I produce a list with a graph and the coefficients (via latex) alternating and then use graphics_array(). However I would prefer to group the primitives in a graph and in the latex and then scale these and place them myself.

Edit This is the code for my second question. The variable a is a formal linear sum (using CombinatorialFreeModule). The function circlepacking takes a graph and produces a graphics object.

r = a.monomial_coefficients()
pics = []
for f in r:
    c = r[f]
    if c == 1: lt = "$+$"
    elif c == -1: lt = "$-$"
    else: lt = "$+("+latex(c)+")$"

I have looked at the matplotlib home page. I can see that there is a class Figure and so on. Should I be attempting to use these since I am working in sage?

I have used metapost and tikz in the past but not matlab.

P.S. I tried g=DiGraph() g.plot? and was directed to a file

2010-10-14 16:11:11 -0500 received badge  Editor (source)
2010-10-14 16:11:11 -0500 received badge  Student (source)
2010-10-14 16:11:11 -0500 received badge  Scholar (source)
2010-09-03 05:13:32 -0500 answered a question Structure constants for unitary groups

I suspect that you have not had a response because your question is not clear. First of all from the expression you give it looks as though you want the structure constants of a Lie algebra. Secondly the cross product of vectors in 3D gives the Lie algebra of SO(3) or SU(2). The Lie algebra of SU(3) has dimension 8. Your question asks for the definition of the structure constants which is a mathematical question. If you are asking a mathematical question you would be better off on another site, probably If you are asking about an implementation in sage you should be clear about the mathematics.

2010-09-02 22:29:19 -0500 commented answer Using CombinatorialFreeModule

Jason, This seems to do what I want. Thanks for your help.

2010-09-02 21:01:04 -0500 marked best answer Using CombinatorialFreeModule

Here is a minimal example that may do what you want:

class Foo(SageObject):
    # This class defines what a 'Foo' is and what can be done with it.
    def __init__(self, i):
        self.i = i

    def _repr_(self):
        return str(self.i)

class Foos(Parent, UniqueRepresentation):
    # This class represents the set of all 'Foo's
    def __contains__(self, f):
        return isinstance(f, Foo)

    Element = Foo

Here is how to use this with CombinatorialFreeModule:

sage: F = Foos()
sage: f = Foo(1)
sage: g = Foo(2)
sage: f
sage: g
sage: f + g
TypeError: unsupported operand type(s) for +: 'Foo' and 'Foo'
sage: M = CombinatorialFreeModule(QQ, F)
sage: a = M.monomial(f)
sage: b = M.monomial(g)
sage: a + b
B[2] + B[1]
sage: 2*a
2010-09-01 07:48:17 -0500 commented answer Using CombinatorialFreeModule

I agree that Parents and Elements will come into this. I have tried reading the documentation on Categories and I have simply not grasped the idea.

2010-09-01 06:54:19 -0500 commented answer Using CombinatorialFreeModule

My class does not have addition and multiplication. This is purely formal (as in, for example, the group algebra of a group which may be infinite).

2010-09-01 06:53:00 -0500 commented answer Using CombinatorialFreeModule

The examples in the documentation give finite lists. I require the (potentially) infinite set of all instances of a class.

2010-09-01 00:30:58 -0500 asked a question Using CombinatorialFreeModule

Could I please have some help on using CombinatorialFreeModule? I have looked at the documentation and the only examples are free modules on a finite set. I have designed my own class and I now want to work with linear combinations of instances of the class. I have been told that one issue is that instances have to be immutable (so they can be hashed?). The attributes of my class are all integers and tuples (of integers). However I am not sure if this is sufficient.

Let's say I have defined a class G whose attributes are all integers and tuples. Then the idea would be say M = CombinatorialFreeModule(QQ,G) to define the free module on instances of G with rational coefficients. Then if g,h,k are instances of G I would hope to be able to put say a = (2/3)g + 4h and b = (-3)h + 2k be able to add these and multiply by rational numbers.

For example, a simple (but inefficient) way to calculate the chromatic polynomial of a graph would be to use contraction/deletion. This starts with a graph and finishes with a polynomial but the intermediate stages are formal linear combinations of graphs. Similarly the skein relation approach to link polynomials has intermediate stages which are formal linear combinations of link projections.

2010-08-19 10:14:06 -0500 asked a question Quantum binomials

What is the difference between q.analogues.q_binomial(n,k) and gaussian_binomial(n,k)? Superficially they seem to be the same.