Skip to content

Commit

Permalink
Trac #34289: minor tweaks in the doc
Browse files Browse the repository at this point in the history
little details, mainly cosmetics

URL: https://trac.sagemath.org/34289
Reported by: chapoton
Ticket author(s): Frédéric Chapoton
Reviewer(s): Matthias Koeppe
  • Loading branch information
Release Manager committed Aug 27, 2022
2 parents 75ae420 + b3ab217 commit 9b5044a
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 118 deletions.
112 changes: 58 additions & 54 deletions src/doc/en/developer/coding_in_other.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ convert output from PARI to Sage objects:
def frobenius(self, flag=0, var='x'):
"""
Return the Frobenius form (rational canonical form) of this
matrix.
Return the Frobenius form (rational canonical form) of this matrix.
INPUT:
Expand All @@ -125,7 +124,7 @@ convert output from PARI to Sage objects:
- ``var`` -- a string (default: 'x')
ALGORITHM: uses PARI's matfrobenius()
ALGORITHM: uses PARI's :pari:`matfrobenius`
EXAMPLES::
Expand All @@ -143,15 +142,15 @@ convert output from PARI to Sage objects:
raise ArithmeticError("frobenius matrix of non-square matrix not defined.")
v = self.__pari__().matfrobenius(flag)
if flag==0:
if flag == 0:
return self.matrix_space()(v.python())
elif flag==1:
elif flag == 1:
r = PolynomialRing(self.base_ring(), names=var)
retr = []
for f in v:
retr.append(eval(str(f).replace("^","**"), {'x':r.gen()}, r.gens_dict()))
return retr
elif flag==2:
elif flag == 2:
F = matrix_space.MatrixSpace(QQ, self.nrows())(v[0].python())
B = matrix_space.MatrixSpace(QQ, self.nrows())(v[1].python())
return F, B
Expand Down Expand Up @@ -212,11 +211,13 @@ object.
Return the Cartan matrix of given Chevalley type and rank.
INPUT:
type -- a Chevalley letter name, as a string, for
a family type of simple Lie algebras
rank -- an integer (legal for that type).
EXAMPLES:
- type -- a Chevalley letter name, as a string, for
a family type of simple Lie algebras
- rank -- an integer (legal for that type).
EXAMPLES::
sage: cartan_matrix("A",5)
[ 2 -1 0 0 0]
[-1 2 -1 0 0]
Expand All @@ -227,12 +228,11 @@ object.
[ 2 -1]
[-3 2]
"""
L = gap.SimpleLieAlgebra('"%s"'%type, rank, 'Rationals')
L = gap.SimpleLieAlgebra('"%s"' % type, rank, 'Rationals')
R = L.RootSystem()
sM = R.CartanMatrix()
ans = eval(str(sM))
MS = MatrixSpace(QQ, rank)
MS = MatrixSpace(QQ, rank)
return MS(ans)
The output ``ans`` is a Python list. The last two lines convert that
Expand Down Expand Up @@ -460,50 +460,51 @@ just that.
.. CODE-BLOCK:: python
def points_parser(string_points,F):
def points_parser(string_points, F):
"""
This function will parse a string of points
of X over a finite field F returned by Singular's NSplaces
command into a Python list of points with entries from F.
EXAMPLES:
EXAMPLES::
sage: F = GF(5)
sage: points_parser(L,F)
((0, 1, 0), (3, 4, 1), (0, 0, 1), (2, 3, 1), (3, 1, 1), (2, 2, 1))
"""
Pts=[]
n=len(L)
#start block to compute a pt
L1=L
while len(L1)>32:
idx=L1.index(" ")
pt=[]
## start block1 for compute pt
idx=L1.index(" ")
idx2=L1[idx:].index("\n")
L2=L1[idx:idx+idx2]
Pts = []
n = len(L)
# start block to compute a pt
L1 = L
while len(L1) > 32:
idx =L1.index(" ")
pt = []
# start block1 for compute pt
idx = L1.index(" ")
idx2 = L1[idx:].index("\n")
L2 = L1[idx:idx+idx2]
pt.append(F(eval(L2)))
# end block1 to compute pt
L1=L1[idx+8:] # repeat block 2 more times
## start block2 for compute pt
idx=L1.index(" ")
idx2=L1[idx:].index("\n")
L2=L1[idx:idx+idx2]
L1 = L1[idx+8:] # repeat block 2 more times
# start block2 for compute pt
idx = L1.index(" ")
idx2 = L1[idx:].index("\n")
L2 = L1[idx:idx+idx2]
pt.append(F(eval(L2)))
# end block2 to compute pt
L1=L1[idx+8:] # repeat block 1 more time
## start block3 for compute pt
# start block3 for compute pt
idx=L1.index(" ")
if "\n" in L1[idx:]:
idx2=L1[idx:].index("\n")
idx2 = L1[idx:].index("\n")
else:
idx2=len(L1[idx:])
L2=L1[idx:idx+idx2]
idx2 = len(L1[idx:])
L2 = L1[idx:idx+idx2]
pt.append(F(eval(L2)))
# end block3 to compute pt
#end block to compute a pt
# end block to compute a pt
Pts.append(tuple(pt)) # repeat until no more pts
L1=L1[idx+8:] # repeat block 2 more times
L1 = L1[idx+8:] # repeat block 2 more times
return tuple(Pts)
Now it is an easy matter to put these ingredients together into a Sage
Expand All @@ -519,20 +520,23 @@ ourselves to points of degree one.
.. CODE-BLOCK:: python
def places_on_curve(f,F):
def places_on_curve(f, F):
"""
INPUT:
f -- element of F[x,y], defining X: f(x,y)=0
F -- a finite field of *prime order*
- f -- element of F[x,y], defining X: f(x,y)=0
- F -- a finite field of *prime order*
OUTPUT:
integer -- the number of places in X of degree d=1 over F
EXAMPLES:
sage: F=GF(5)
sage: R=PolynomialRing(F,2,names=["x","y"])
sage: x,y=R.gens()
sage: f=y^2-x^9-x
integer -- the number of places in X of degree d=1 over F
EXAMPLES::
sage: F = GF(5)
sage: R = PolynomialRing(F,2,names=["x","y"])
sage: x,y = R.gens()
sage: f = y^2-x^9-x
sage: places_on_curve(f,F)
((0, 1, 0), (3, 4, 1), (0, 0, 1), (2, 3, 1), (3, 1, 1), (2, 2, 1))
"""
Expand Down Expand Up @@ -600,7 +604,7 @@ function is not required:

.. CODE-BLOCK:: python
def places_on_curve(f,F):
def places_on_curve(f, F):
p = F.characteristic()
if F.degree() > 1:
raise NotImplementedError
Expand Down Expand Up @@ -677,7 +681,7 @@ This uses the class ``Expect`` to set up the Octave interface:
"""
Set the variable var to the given value.
"""
cmd = '%s=%s;'%(var,value)
cmd = '%s=%s;' % (var,value)
out = self.eval(cmd)
if out.find("error") != -1:
raise TypeError("Error executing code in Octave\nCODE:\n\t%s\nOctave ERROR:\n\t%s"%(cmd, out))
Expand All @@ -686,7 +690,7 @@ This uses the class ``Expect`` to set up the Octave interface:
"""
Get the value of the variable var.
"""
s = self.eval('%s'%var)
s = self.eval('%s' % var)
i = s.find('=')
return s[i+1:]
Expand Down Expand Up @@ -729,16 +733,16 @@ dumps the user into an Octave interactive shell:
raise ValueError("dimensions of A and b must be compatible")
from sage.matrix.all import MatrixSpace
from sage.rings.all import QQ
MS = MatrixSpace(QQ,m,1)
b = MS(list(b)) # converted b to a "column vector"
MS = MatrixSpace(QQ, m, 1)
b = MS(list(b)) # converted b to a "column vector"
sA = self.sage2octave_matrix_string(A)
sb = self.sage2octave_matrix_string(b)
self.eval("a = " + sA )
self.eval("b = " + sb )
soln = octave.eval("c = a \\ b")
soln = soln.replace("\n\n ","[")
soln = soln.replace("\n\n","]")
soln = soln.replace("\n",",")
soln = soln.replace("\n\n ", "[")
soln = soln.replace("\n\n", "]")
soln = soln.replace("\n", ",")
sol = soln[3:]
return eval(sol)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ The vertices of the `n`-cube can be described by vectors in
The distance function measures in how many slots two vectors in
`\mathbb{Z}_2^n` differ::

sage: u=(1,0,1,1,1,0)
sage: v=(0,0,1,1,0,0)
sage: u = (1,0,1,1,1,0)
sage: v = (0,0,1,1,0,0)
sage: dist(u,v)
2

Expand Down
3 changes: 1 addition & 2 deletions src/doc/en/thematic_tutorials/lie/affine.rst
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ The column vector `a` with these entries spans the nullspace of `A`::

sage: RS = RootSystem(['E',6,2]); RS
Root system of type ['F', 4, 1]^*
sage: A=RS.cartan_matrix(); A
sage: A = RS.cartan_matrix(); A
[ 2 -1 0 0 0]
[-1 2 -1 0 0]
[ 0 -1 2 -2 0]
Expand Down Expand Up @@ -471,4 +471,3 @@ It may be constructed in Sage as follows::
See the documentation in
:mod:`~sage.combinat.root_system.extended_affine_weyl_group`
if you need this.

35 changes: 17 additions & 18 deletions src/doc/en/thematic_tutorials/lie/branching_rules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Sage has a class ``BranchingRule`` for branching rules. The function
the natural embedding of `Sp(4)` into `SL(4)` corresponds to
the branching rule that we may create as follows::

sage: b=branching_rule("A3","C2",rule="symmetric"); b
sage: b = branching_rule("A3","C2",rule="symmetric"); b
symmetric branching rule A3 => C2

The name "symmetric" of this branching rule will be
Expand All @@ -62,10 +62,10 @@ Here ``A3`` and ``C2`` are the Cartan types of the groups
Now we may see how representations of `SL(4)` decompose
into irreducibles when they are restricted to `Sp(4)`::

sage: A3=WeylCharacterRing("A3",style="coroots")
sage: chi=A3(1,0,1); chi.degree()
sage: A3 = WeylCharacterRing("A3",style="coroots")
sage: chi = A3(1,0,1); chi.degree()
15
sage: C2=WeylCharacterRing("C2",style="coroots")
sage: C2 = WeylCharacterRing("C2",style="coroots")
sage: chi.branch(C2,rule=b)
C2(0,1) + C2(2,0)

Expand Down Expand Up @@ -95,13 +95,13 @@ Observe that we do not have to build the intermediate

::

sage: C4=WeylCharacterRing("C4",style="coroots")
sage: b1=branching_rule("C4","A3","levi")*branching_rule("A3","C2","symmetric"); b1
sage: C4 = WeylCharacterRing("C4",style="coroots")
sage: b1 = branching_rule("C4","A3","levi")*branching_rule("A3","C2","symmetric"); b1
composite branching rule C4 => (levi) A3 => (symmetric) C2
sage: b2=branching_rule("C4","C2xC2","orthogonal_sum")*branching_rule("C2xC2","C2","proj1"); b2
sage: b2 = branching_rule("C4","C2xC2","orthogonal_sum")*branching_rule("C2xC2","C2","proj1"); b2
composite branching rule C4 => (orthogonal_sum) C2xC2 => (proj1) C2
sage: C2=WeylCharacterRing("C2",style="coroots")
sage: C4=WeylCharacterRing("C4",style="coroots")
sage: C2 = WeylCharacterRing("C2",style="coroots")
sage: C4 = WeylCharacterRing("C4",style="coroots")
sage: [C4(2,0,0,1).branch(C2, rule=br) for br in [b1,b2]]
[4*C2(0,0) + 7*C2(0,1) + 15*C2(2,0) + 7*C2(0,2) + 11*C2(2,1) + C2(0,3) + 6*C2(4,0) + 3*C2(2,2),
10*C2(0,0) + 40*C2(1,0) + 50*C2(0,1) + 16*C2(2,0) + 20*C2(1,1) + 4*C2(3,0) + 5*C2(2,1)]
Expand Down Expand Up @@ -187,7 +187,7 @@ Sage has a database of maximal subgroups for every simple Cartan
type of rank `\le 8`. You may access this with the
``maximal_subgroups`` method of the Weyl character ring::

sage: E7=WeylCharacterRing("E7",style="coroots")
sage: E7 = WeylCharacterRing("E7",style="coroots")
sage: E7.maximal_subgroups()
A7:branching_rule("E7","A7","extended")
E6:branching_rule("E7","E6","levi")
Expand All @@ -212,7 +212,7 @@ as follows::

sage: b = E7.maximal_subgroup("A2"); b
miscellaneous branching rule E7 => A2
sage: [E7,A2]=[WeylCharacterRing(x,style="coroots") for x in ["E7","A2"]]
sage: E7, A2 = [WeylCharacterRing(x,style="coroots") for x in ["E7","A2"]]
sage: E7(1,0,0,0,0,0,0).branch(A2,rule=b)
A2(1,1) + A2(4,4)

Expand All @@ -236,8 +236,8 @@ complete up to inner automorphisms. For example, `E_6` has a
nontrivial Dynkin diagram automorphism so it has an outer
automorphism that is not inner::

sage: [E6,A2xG2]=[WeylCharacterRing(x,style="coroots") for x in ["E6","A2xG2"]]
sage: b=E6.maximal_subgroup("A2xG2"); b
sage: E6, A2xG2 = [WeylCharacterRing(x,style="coroots") for x in ["E6","A2xG2"]]
sage: b = E6.maximal_subgroup("A2xG2"); b
miscellaneous branching rule E6 => A2xG2
sage: E6(1,0,0,0,0,0).branch(A2xG2,rule=b)
A2xG2(0,1,1,0) + A2xG2(2,0,0,0)
Expand All @@ -250,7 +250,7 @@ the `A_2\times G_2` subgroup is changed to a different one
by the outer automorphism. To obtain the second branching
rule, we compose the given one with this automorphism::

sage: b1=branching_rule("E6","E6","automorphic")*b; b1
sage: b1 = branching_rule("E6","E6","automorphic")*b; b1
composite branching rule E6 => (automorphic) E6 => (miscellaneous) A2xG2

.. _levi_branch_rules:
Expand Down Expand Up @@ -533,8 +533,8 @@ construct the branching rule to `A_5` we may proceed as follows::

sage: b = branching_rule("E6","A5xA1","extended")*branching_rule("A5xA1","A5","proj1"); b
composite branching rule E6 => (extended) A5xA1 => (proj1) A5
sage: E6=WeylCharacterRing("E6",style="coroots")
sage: A5=WeylCharacterRing("A5",style="coroots")
sage: E6 = WeylCharacterRing("E6",style="coroots")
sage: A5 = WeylCharacterRing("A5",style="coroots")
sage: E6(0,1,0,0,0,0).branch(A5,rule=b)
3*A5(0,0,0,0,0) + 2*A5(0,0,1,0,0) + A5(1,0,0,0,1)
sage: b.describe()
Expand Down Expand Up @@ -1006,7 +1006,7 @@ representation of `SO(8)` and the two
eight-dimensional spin representations. These are
permuted by triality::

sage: D4=WeylCharacterRing("D4",style="coroots")
sage: D4 = WeylCharacterRing("D4",style="coroots")
sage: D4(0,0,0,1).branch(D4,rule="triality")
D4(1,0,0,0)
sage: D4(0,0,0,1).branch(D4,rule="triality").branch(D4,rule="triality")
Expand All @@ -1021,4 +1021,3 @@ spin representations, as it always does in type `D`::
D4(0,0,1,0)
sage: D4(0,0,1,0).branch(D4,rule="automorphic")
D4(0,0,0,1)

Loading

0 comments on commit 9b5044a

Please sign in to comment.