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. picture of B2 where alpha[2] points east and
        #       alpha[1] points northwest
        root_coords = [ vector((r.coefficient(1), r.coefficient(0)))
                        for r in roots ]
        wt_coords = [ ((wt.coefficient(1), wt.coefficient(0)), m)
                      for (wt,m) in self.mlist() ]
    # Type G2: alpha[1] is short
    elif tuple(self.cartan_type()) == ('G',2):
        G2 = WeylCharacterRing(['G',2])
        roots = G2.space().roots()
        root_coords =
[ g2_2d_coords(vector(map(r.coefficient,range(3))))
                      for r in roots ]
        wt_coords =
[ (tuple(g2_2d_coords(vector(map(wt.coefficient,range(3))))), m)
                      for (wt,m) in self.mlist() ]
    else:
        raise NotImplementedError('Plotting is not implemented for
this type')

    root_plot = sum(plot(v,**arrow_style) for v in root_coords)
    wt_plot = sum([point(wt, size=mult_scale(m), **point_style)
                   for (wt,m) in wt_coords])
    if plot_roots:
        return wt_plot+root_plot
    else:
        return wt_plot


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:

WeightRingElement.demazure_character(w) # w = Weyl group element
WeightRingElement._demazure_character(i) # helper method; i = index of
simple root
WeightRingElement.plot( ... ) # plot method for types A2, B2, G2, A1 x
A1
WeightRingElement.degree() # as above

I can wait until #7922 is reviewed, or defer to someone else with more
experience here.

--
Benjamin Jones
[email protected]

On Jan 31, 3:17 am, "Nicolas M. Thiery" <[email protected]>
wrote:
>         Dear Adrien, Anne, Benjamin, Dan, Vivianne, Nicolas, ...
>
> We should make sure to keep Benjamin in CC, since I am not sure he is
> on sage-combinat-devel (I bounced his message which was originally on
> sage-devel).
>
>
>
>
>
>
>
>
>
> On Sun, Jan 30, 2011 at 04:07:09PM -0800, bump wrote:
> > 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.
>
> 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?
>
> By the way some suggestions for the code above:
>  - .space() -> .basis().indices() ?
>  - self._parent -> self.parent()
>  - d = self._mdict; d.keys()  ->  self.support()
>  - sum -> self.sum()
>  - P(i) -> self.monomial(i)   (where P is self._parent above)
>
> Ooooops, but all those comments are assuming that #7922 is applied,
> which I still haven't reviewed ... Ok, that going up my TODO pile ...
>
> Cheers,
>                                 Nicolas
> --
> Nicolas M. Thi�ry "Isil" <[email protected]>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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-combinat-devel?hl=en.

Reply via email to