Re: [sage-combinat-devel] Re: [sage-devel] Re: post more

2011-01-31 Thread Daniel Bump

 Ops, but all those comments are assuming that #7922 is applied,
 which I still haven't reviewed ... Ok, that going up my TODO pile ...

The code snippet I posted does not assume #7922.

At this moment #7922 needs work since it changes the
syntax of a few things enough to break some tests in
the tutorial #8442, which has been merged. I'm happy to
revise the tutorial if you or someone is ready to
review #7922. The changes to the tutorial will not
be very big.

Dan

-- 
You received this message because you are subscribed to the Google Groups 
sage-combinat-devel group.
To post to this group, send email to sage-combinat-devel@googlegroups.com.
To unsubscribe from this group, send email to 
sage-combinat-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sage-combinat-devel?hl=en.



[sage-combinat-devel] Re: [sage-devel] Re: post more

2011-01-31 Thread bump

Nicolas wrote:

 This looks very related to what Vivianne (and Adrien and Nicolas) is
 implementing around Schubert polynomials and the like. Vivianne: can
 you already compute demazure characters with your code?
 (WeylCharacterRing is basically the group algebra of the ambient
 lattice)? If yes, could you give an example here?

No, the WeylCharacterRing is the representation ring of the Lie
group. A basis is indexed by dominant characters. The WeightRing
is the group algebra of the lattice.

Dan

-- 
You received this message because you are subscribed to the Google Groups 
sage-combinat-devel group.
To post to this group, send email to sage-combinat-devel@googlegroups.com.
To unsubscribe from this group, send email to 
sage-combinat-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sage-combinat-devel?hl=en.



Re: [sage-combinat-devel] Re: [sage-devel] Re: post more

2011-01-31 Thread Nicolas M. Thiery
On Mon, Jan 31, 2011 at 06:11:18AM -0800, Daniel Bump wrote:
 The code snippet I posted does not assume #7922.

Yup, only my comments about it :-)

 At this moment #7922 needs work since it changes the syntax of a few
 things enough to break some tests in the tutorial #8442, which has
 been merged. I'm happy to revise the tutorial if you or someone is
 ready to review #7922. The changes to the tutorial will not be very
 big.

Ok. I'll send you a ping when I'll be ready for reviewing.

Cheers,
Nicolas
--
Nicolas M. Thiéry Isil nthi...@users.sf.net
http://Nicolas.Thiery.name/

-- 
You received this message because you are subscribed to the Google Groups 
sage-combinat-devel group.
To post to this group, send email to sage-combinat-devel@googlegroups.com.
To unsubscribe from this group, send email to 
sage-combinat-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sage-combinat-devel?hl=en.



Re: [sage-combinat-devel] Re: [sage-devel] Re: post more

2011-01-31 Thread Nicolas M. Thiery
On Mon, Jan 31, 2011 at 07:05:27AM -0800, bump wrote:
 No, the WeylCharacterRing is the representation ring of the Lie
 group. A basis is indexed by dominant characters. The WeightRing
 is the group algebra of the lattice.

Oops, thanks for catching this; I indeed meant WeightRing.

Cheers,
Nicolas
--
Nicolas M. Thiéry Isil nthi...@users.sf.net
http://Nicolas.Thiery.name/

-- 
You received this message because you are subscribed to the Google Groups 
sage-combinat-devel group.
To post to this group, send email to sage-combinat-devel@googlegroups.com.
To unsubscribe from this group, send email to 
sage-combinat-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sage-combinat-devel?hl=en.



[sage-combinat-devel] Re: [sage-devel] Re: post more

2011-01-31 Thread BFJ
Hi all,

Thanks for the replies. I'm on the sage-combinat-devel list now.

I don't know if it's helpful to post so much code, but here is my code
for the Demazure character and rank 2 plotting. The Demazure character
code contains the same idea as bump's code.

def demazure(ch, i):

EXAMPLES:
# Check the Demazure character formula in A2
sage: A = WeylCharacterRing(['A',2])
sage: a = WeightRing(A)
sage: space = a.space()
sage: lam = space.fundamental_weights()
sage: rho = sum(list(lam))
sage: wch = A(2*rho) # character of the irred. representation
sage: ch = a(2*rho)  # element in the weight ring
sage: dch = demazure(ch,[2,1,2]) # apply 3 Demazure operators
sage: sorted(wch.mlist()) == sorted(dch.mlist())
True

# Check the Demazure character formula in B2
sage: A = WeylCharacterRing(['B',2])
sage: a = WeightRing(A)
sage: space = a.space()
sage: lam = space.fundamental_weights()
sage: rho = sum(list(lam))
sage: wch = A(2*rho) # character of the irred. representation
sage: ch = a(2*rho)  # element in the weight ring
sage: dch = demazure(ch,[1,2,1,2]) # apply 4 Demazure
operators
sage: sum([m for (wt,m) in dch.mlist()]) # degree should be 81
81
sage: sorted(wch.mlist()) == sorted(dch.mlist())
True


a = ch.parent()
# passing a list applies the operators in the indicated order
# elements of i index simple roots
if type(i) == list:
ch_temp = copy(ch)
for j in i:
ch_temp = demazure(ch_temp, j)
return ch_temp
# otherwise i is an index for a simple root
space = a.space()
if i not in space.index_set():
raise IndexError('%s does not index a simple root' %
i.__str__())
alpha = space.simple_root(i) # if i is in space.index_set()
ch_temp=a(0)
for (wt,wtm) in ch.mlist():
n = wt.scalar(2*alpha/alpha.scalar(alpha))
if n = 0:
ch_temp += wtm * sum([a(wt-i*alpha) for i in range(n+1)])
if n == -1: # for clarity
ch_temp += 0
if n = -2:
ch_temp += wtm * sum([-1*a(wt+i*alpha) for i in range(1,-
n)])
return ch_temp

I agree with the design comments bump has. I think it would also be
useful to have a degree method in WeightRingElement:

def degree(self):

The degree of the character, that is, the dimension of module.

EXAMPLES::

sage: b = WeightRing(WeylCharacterRing(['B',2]))
sage: ch = 3*b((3,1)) + 2*b((2,1)) + b((1,1))
sage: ch.degree()
6

return sum(self._mdict[k] for k in self._mdict)

Here is the code for 2d plotting. There are helper functions for
computing coordinates in A2 and G2, and then the plot() method.

def sl3_2d_coords(v):

INPUT:
v = 3d vector lying in the plane x+y+z=0

OUTPUT:
2d vector of coordinates with respect to basis vectors:
u1 = vector((1/2, -1/2, 0))
u2 = vector((1/2*sqrt(1/2)*sqrt(2/3), 1/2*sqrt(1/2)*sqrt(2/3),
  -sqrt(1/2)*sqrt(2/3)))

u1 = vector((1/2, -1/2, 0))
u2 = vector((1/2*sqrt(1/2)*sqrt(2/3), 1/2*sqrt(1/2)*sqrt(2/3),
  -sqrt(1/2)*sqrt(2/3)))
return vector((v*u1, v*u2))

def g2_2d_coords(v):

INPUT:
v = 3d vector lying in the plane x+y+z=0

OUTPUT:
2d vector of coordinates with respect to basis vectors:
u1 = vector((0, 1, -1))
u2 = vector((1, -1/2, -1/2))

u1 = vector((0, 1, -1))
u2 = vector((1, -1/2, -1/2))
return vector((v*u1, v*u2))


def plot(self, plot_roots=True, arrow_style=None, point_style=None,
mult_scale=None):

Plot the character if cartan type is rank 2.

EXAMPLES::

sage: A = WeylCharacterRing(['B',2])
sage: a = WeightRing(A)
sage: lam = a.space().fundamental_weights()
sage: M = demazure(a(4*lam[1]+4*lam[2]), [1,2])
sage: M.plot()

# plot parameters
if arrow_style == None:
arrow_style={'rgbcolor':(0,0,1),'width':
1,'linestyle':'dotted'}
if point_style == None:
point_style={'rgbcolor':(1,0,0)}
if mult_scale == None:
mult_scale = lambda m: m^2*10

# Type A2
if tuple(self.cartan_type()) == ('A',2):
A2 = WeylCharacterRing(['A',2])
roots = A2.space().roots()

# compute coordinates of the roots
root_coords = [ sl3_2d_coords(vector(A2.coerce_to_sl(r)))
  for r in roots ]
# compute coordinates of the weights and store with
multiplicity
wt_coords =
[ (tuple(sl3_2d_coords(vector(A2.coerce_to_sl(wt,m)
  for (wt,m) in self.mlist() ]
# Type B2: alpha[2] is short
elif tuple(self.cartan_type()) == ('B',2):
B2 = WeylCharacterRing(['B',2])
roots = B2.space().roots()
# Note: we reflect about the line y=x here to be consistent
with
#   the std. 

Re: [sage-combinat-devel] Re: [sage-devel] Re: post more

2011-01-31 Thread Daniel Bump

 I don't know if it's helpful to post so much code, but here is my code
 for the Demazure character and rank 2 plotting. The Demazure character
 code contains the same idea as bump's code.

There were a couple of mistakes in the code snippet that I posted.

Here is another attempt, probably correct:

http://match.stanford.edu/bump/patches/demazure.patch

After this patch you can do this:

sage: B2 = WeylCharacterRing(B2)
sage: b2 = WeightRing(B2)
sage: W = B2.space().weyl_group(prefix=s)
sage: [s1,s2] = W. simple_reflections()
sage: w0 = W.long_element()
sage: [b2(h).demazure(w0) for h in B2.space().fundamental_weights()]
[b2(-1,0) + b2(0,-1) + b2(0,0) + b2(0,1) + b2(1,0), b2(-1/2,-1/2) + 
b2(-1/2,1/2) + b2(1/2,-1/2) + b2(1/2,1/2)]
sage: [b2(B2(h)) == b2(h).demazure(w0) for h in 
B2.space().fundamental_weights()]
[True, True]

 I should add more examples and flesh out the docstrings, of course. I
 need to clean up my plotting code a bit as well.
 
 I'd be happy to start a ticket to add the following methods to
 WeightRingElement:

Sure, go ahead and make a ticket. If you want to work on a patch, I can kibbitz.
I won't work on this any more if you want to do it. (I need Demazure
characters for my own work.)

As for waiting for #7922, my belief is that the amount of code that we are
talking about is not so great that we cannot reimplement quickly. So we
should not wait.

Dan

-- 
You received this message because you are subscribed to the Google Groups 
sage-combinat-devel group.
To post to this group, send email to sage-combinat-devel@googlegroups.com.
To unsubscribe from this group, send email to 
sage-combinat-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sage-combinat-devel?hl=en.



[sage-combinat-devel] Re: [sage-devel] Re: post more

2011-01-30 Thread bump
I too needed some code to compute with Demazure characters using the
weight ring.
I agree that this is useful independent of the Demazure characters as
implemented
in the crystal code.

What we did was just to make a standalone program that did what we
needed, but it would make a good enhancement to sage.
I think the right way would be as a method of the weight ring.
So the syntax would be

ch.demazure_character(w)

where ch is a weight ring element and w is an element of the Weyl
group.
There could be a helper method

ch._demazure_character(i)

that would produce the operator corresponding to the i-th simple
reflection.
It would do something like this:

def _demazure(self, i):
a = self._parent.space().simple_coroots()[i]
ret = self._parent(0)
d = self._mdict
for t in d.keys():
k = t.inner_product(a)
if k = 0:
ret += d[t]*sum(self._parent(t-j*a) for j in range(k
+1))
else:
ret += -d[t]*sum(self._parent(t+j*a) for j in
range(1,k))
return ret

This helper method would then be called by the method demazure,
which would use the reduced_word method of Weyl group elements
to to produce a sequence of called to the helper method.

The plot method for WeightRingElements, just for rank two, would
also be very useful.

-- 
You received this message because you are subscribed to the Google Groups 
sage-combinat-devel group.
To post to this group, send email to sage-combinat-devel@googlegroups.com.
To unsubscribe from this group, send email to 
sage-combinat-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sage-combinat-devel?hl=en.