Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,19 @@ class FiniteDimensionalAlgebraIdeal(Ideal_generic):

EXAMPLES::

sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])])
sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]),
....: Matrix([[0, 1], [0, 0]])])
sage: A.ideal(A([0,1]))
Ideal (e1) of Finite-dimensional algebra of degree 2 over Finite Field of size 3
"""
def __init__(self, A, gens=None, given_by_matrix=False):
"""
EXAMPLES::

sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])])
sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]),
....: Matrix([[0, 1], [0, 0]])])
sage: I = A.ideal(A([0,1]))
sage: TestSuite(I).run(skip="_test_category") # Currently ideals are not using the category framework
sage: TestSuite(I).run(skip="_test_category") # Currently ideals are not using the category framework
"""
k = A.base_ring()
n = A.degree()
Expand All @@ -76,7 +78,8 @@ def _richcmp_(self, other, op):

TESTS::

sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])])
sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]),
....: Matrix([[0, 1], [0, 0]])])
sage: I = A.ideal(A([1,1]))
sage: J = A.ideal(A([0,1]))
sage: I == J
Expand All @@ -86,7 +89,8 @@ def _richcmp_(self, other, op):
sage: I == I + J
True

sage: A2 = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])])
sage: A2 = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]),
....: Matrix([[0, 1], [0, 0]])])
sage: A is A2
True
sage: A == A2
Expand Down Expand Up @@ -130,7 +134,8 @@ def __contains__(self, elt):
"""
EXAMPLES::

sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])])
sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]),
....: Matrix([[0, 1], [0, 0]])])
sage: J = A.ideal(A([0,1]))
sage: A([0,1]) in J
True
Expand All @@ -147,7 +152,8 @@ def basis_matrix(self):

EXAMPLES::

sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])])
sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]),
....: Matrix([[0, 1], [0, 0]])])
sage: I = A.ideal(A([1,1]))
sage: I.basis_matrix()
[1 0]
Expand All @@ -162,7 +168,8 @@ def vector_space(self):

EXAMPLES::

sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]), Matrix([[0, 1], [0, 0]])])
sage: A = FiniteDimensionalAlgebra(GF(3), [Matrix([[1, 0], [0, 1]]),
....: Matrix([[0, 1], [0, 0]])])
sage: I = A.ideal(A([1,1]))
sage: I.vector_space()
Vector space of degree 2 and dimension 2 over Finite Field of size 3
Expand Down
10 changes: 5 additions & 5 deletions src/sage/arith/functions.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@ def lcm(a, b=None):

EXAMPLES::

sage: lcm(97,100)
sage: lcm(97, 100)
9700
sage: LCM(97,100)
sage: LCM(97, 100)
9700
sage: LCM(0,2)
sage: LCM(0, 2)
0
sage: LCM(-3,-5)
sage: LCM(-3, -5)
15
sage: LCM([1,2,3,4,5])
60
sage: v = LCM(range(1,10000)) # *very* fast!
sage: v = LCM(range(1, 10000)) # *very* fast!
sage: len(str(v))
4349

Expand Down
4 changes: 2 additions & 2 deletions src/sage/arith/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3748,9 +3748,9 @@ def binomial(x, m, **kwds):
Some floating point cases -- see :issue:`7562`, :issue:`9633`, and
:issue:`12448`::

sage: binomial(1., 3)
sage: binomial(1., 3) # needs sage.rings.real_mpfr
0.000000000000000
sage: binomial(-2., 3)
sage: binomial(-2., 3) # needs sage.rings.real_mpfr
-4.00000000000000
sage: binomial(0.5r, 5)
0.02734375
Expand Down
21 changes: 14 additions & 7 deletions src/sage/arith/srange.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -234,16 +234,21 @@ def srange(*args, **kwds):

sage: srange(1, 10, 1/2)
[1, 3/2, 2, 5/2, 3, 7/2, 4, 9/2, 5, 11/2, 6, 13/2, 7, 15/2, 8, 17/2, 9, 19/2]

sage: # needs sage.rings.real_mpfr
sage: srange(1, 5, 0.5)
[1.00000000000000, 1.50000000000000, 2.00000000000000, 2.50000000000000, 3.00000000000000, 3.50000000000000, 4.00000000000000, 4.50000000000000]
[1.00000000000000, 1.50000000000000, 2.00000000000000, 2.50000000000000,
3.00000000000000, 3.50000000000000, 4.00000000000000, 4.50000000000000]
sage: srange(0, 1, 0.4)
[0.000000000000000, 0.400000000000000, 0.800000000000000]
sage: srange(1.0, 5.0, include_endpoint=True)
[1.00000000000000, 2.00000000000000, 3.00000000000000, 4.00000000000000, 5.00000000000000]
[1.00000000000000, 2.00000000000000, 3.00000000000000, 4.00000000000000,
5.00000000000000]
sage: srange(1.0, 1.1)
[1.00000000000000]
sage: srange(1.0, 1.0)
[]

sage: V = VectorSpace(QQ, 2) # needs sage.modules
sage: srange(V([0,0]), V([5,5]), step=V([2,2])) # needs sage.modules
[(0, 0), (2, 2), (4, 4)]
Expand All @@ -264,7 +269,8 @@ def srange(*args, **kwds):
sage: srange(0.5, 0.9, 0.1, universe=RDF, include_endpoint=False)
[0.5, 0.6, 0.7, 0.7999999999999999]
sage: srange(0, 1.1, 0.1, universe=RDF, include_endpoint=True)
[0.0, 0.1, 0.2, 0.30000000000000004, 0.4, 0.5, 0.6, 0.7, 0.7999999999999999, 0.8999999999999999, 0.9999999999999999, 1.1]
[0.0, 0.1, 0.2, 0.30000000000000004, 0.4, 0.5, 0.6, 0.7,
0.7999999999999999, 0.8999999999999999, 0.9999999999999999, 1.1]
sage: srange(0, 0.2, 0.1, universe=RDF, include_endpoint=True)
[0.0, 0.1, 0.2]
sage: srange(0, 0.3, 0.1, universe=RDF, include_endpoint=True)
Expand All @@ -275,9 +281,10 @@ def srange(*args, **kwds):
sage: Q = RationalField()
sage: srange(1, 10, Q('1/2'))
[1, 3/2, 2, 5/2, 3, 7/2, 4, 9/2, 5, 11/2, 6, 13/2, 7, 15/2, 8, 17/2, 9, 19/2]
sage: srange(1, 5, 0.5)
[1.00000000000000, 1.50000000000000, 2.00000000000000, 2.50000000000000, 3.00000000000000, 3.50000000000000, 4.00000000000000, 4.50000000000000]
sage: srange(0, 1, 0.4)
sage: srange(1, 5, 0.5) # needs sage.rings.real_mpfr
[1.00000000000000, 1.50000000000000, 2.00000000000000, 2.50000000000000,
3.00000000000000, 3.50000000000000, 4.00000000000000, 4.50000000000000]
sage: srange(0, 1, 0.4) # needs sage.rings.real_mpfr
[0.000000000000000, 0.400000000000000, 0.800000000000000]

Negative steps are also allowed::
Expand Down Expand Up @@ -512,7 +519,7 @@ def ellipsis_range(*args, step=None):

Examples in which the step determines the parent of the elements::

sage: [1..3, step=0.5]
sage: [1..3, step=0.5] # needs sage.rings.real_mpfr
[1.00000000000000, 1.50000000000000, 2.00000000000000, 2.50000000000000, 3.00000000000000]
sage: v = [1..5, step=1/1]; v
[1, 2, 3, 4, 5]
Expand Down
7 changes: 4 additions & 3 deletions src/sage/game_theory/matching_game.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# sage.doctest: needs sage.graphs
"""
Matching games

Expand Down Expand Up @@ -124,7 +125,7 @@ class MatchingGame(SageObject):

Matchings have a natural representations as bipartite graphs::

sage: plot(m)
sage: plot(m) # needs sage.plot
Graphics object consisting of 13 graphics primitives

The above plots the bipartite graph associated with the matching.
Expand Down Expand Up @@ -508,14 +509,14 @@ def plot(self):
sage: revr = {3: (0, 1),
....: 4: (1, 0)}
sage: g = MatchingGame([suit, revr])
sage: plot(g)
sage: plot(g) # needs sage.plot
Traceback (most recent call last):
...
ValueError: game has not been solved yet

sage: g.solve()
{0: 3, 1: 4}
sage: plot(g)
sage: plot(g) # needs sage.plot
Graphics object consisting of 7 graphics primitives
"""
pl = self.bipartite_graph()
Expand Down
6 changes: 3 additions & 3 deletions src/sage/game_theory/normal_form_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,11 @@
`(Ay)_i`, ie element in position `i` of the matrix/vector multiplication
`Ay`) ::

sage: y = var('y')
sage: y = var('y') # needs sage.symbolic
sage: A = matrix([[1, -1], [-1, 1]])
sage: p = plot((A * vector([y, 1 - y]))[0], y, 0, 1, color='blue',
sage: p = plot((A * vector([y, 1 - y]))[0], y, 0, 1, color='blue', # needs sage.symbolic
....: legend_label='$u_1(r_1, (y, 1-y))$', axes_labels=['$y$', ''])
sage: p += plot((A * vector([y, 1 - y]))[1], y, 0, 1, color='red',
sage: p += plot((A * vector([y, 1 - y]))[1], y, 0, 1, color='red', # needs sage.symbolic
....: legend_label='$u_1(r_2, (y, 1-y))$'); p
Graphics object consisting of 2 graphics primitives

Expand Down
4 changes: 2 additions & 2 deletions src/sage/structure/formal_sum.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def _latex_(self):
r"""
EXAMPLES::

sage: latex(FormalSum([(1,2), (5, 8/9), (-3, 7)]))
sage: latex(FormalSum([(1,2), (5, 8/9), (-3, 7)])) # needs sage.rings.real_mpfr
2 + 5\cdot \frac{8}{9} - 3\cdot 7
"""
from sage.misc.latex import repr_lincomb
Expand Down Expand Up @@ -441,7 +441,7 @@ def _get_action_(self, other, op, self_is_left):
"""
EXAMPLES::

sage: A = FormalSums(RR); A.get_action(RR) # indirect doctest
sage: A = FormalSums(RR); A.get_action(RR) # indirect doctest # needs sage.rings.real_mpfr
Right scalar multiplication by Real Field with 53 bits of precision
on Abelian Group of all Formal Finite Sums over Real Field with 53 bits of precision

Expand Down
2 changes: 2 additions & 0 deletions src/sage/topology/cell_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ def _n_cells_sorted(self, n, subcomplex=None):
sage: K = SimplicialComplex([[1,2,3], [2,3,4]])
sage: Z._n_cells_sorted(2, subcomplex=K)
[(1, 2, 4), (1, 3, 4)]

sage: # needs sage.symbolic
sage: S = SimplicialComplex([[complex(i), complex(1)]])
sage: S._n_cells_sorted(0)
[((1+0j),), (1j,)]
Expand Down
20 changes: 14 additions & 6 deletions src/sage/topology/moment_angle_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
from itertools import combinations

from sage.categories.fields import Fields
from sage.homology.homology_group import HomologyGroup
from sage.misc.cachefunc import cached_method
from sage.misc.lazy_attribute import lazy_attribute
from sage.misc.lazy_import import lazy_import
from sage.rings.integer_ring import ZZ
from sage.rings.rational_field import QQ
from sage.structure.sage_object import SageObject
Expand All @@ -29,6 +29,8 @@
from sage.topology.cubical_complex import CubicalComplex, cubical_complexes
from sage.topology.simplicial_complex import SimplicialComplex, copy

lazy_import('sage.homology.homology_group', 'HomologyGroup')


def _cubical_complex_union(c1, c2):
"""
Expand Down Expand Up @@ -130,11 +132,11 @@ class MomentAngleComplex(UniqueRepresentation, SageObject):
We can perform a number of operations, such as find the dimension or
compute the homology::

sage: M.homology()
sage: M.homology() # needs sage.modules
{0: 0, 1: 0, 2: 0, 3: Z}
sage: Z.dimension()
6
sage: Z.homology()
sage: Z.homology() # needs sage.modules
{0: 0, 1: 0, 2: 0, 3: Z x Z, 4: Z, 5: Z, 6: Z}

If the associated simplicial complex is an `n`-simplex, then the
Expand Down Expand Up @@ -403,9 +405,9 @@ def components(self):

sage: S3 = simplicial_complexes.Sphere(3)
sage: product_of_spheres = S3.product(S3)
sage: Z.cohomology()
sage: Z.cohomology() # needs sage.modules
{0: 0, 1: 0, 2: 0, 3: Z x Z, 4: 0, 5: 0, 6: Z}
sage: Z.cohomology() == product_of_spheres.cohomology() # long time
sage: Z.cohomology() == product_of_spheres.cohomology() # long time # needs sage.modules
True
"""
return self._components
Expand Down Expand Up @@ -453,6 +455,7 @@ def _homology_group(self, i, base_ring, cohomology, algorithm, verbose, reduced)

TESTS::

sage: # needs sage.modules
sage: Z = MomentAngleComplex([[0,1,2], [1,2,3]]); Z
Moment-angle complex of Simplicial complex with vertex set
(0, 1, 2, 3) and facets {(0, 1, 2), (1, 2, 3)}
Expand Down Expand Up @@ -550,6 +553,7 @@ def homology(self, dim=None, base_ring=ZZ, cohomology=False,

EXAMPLES::

sage: # needs sage.modules
sage: Z = MomentAngleComplex([[0,1,2], [1,2,3], [3,0]]); Z
Moment-angle complex of Simplicial complex with vertex set
(0, 1, 2, 3) and facets {(0, 3), (0, 1, 2), (1, 2, 3)}
Expand Down Expand Up @@ -580,13 +584,14 @@ def homology(self, dim=None, base_ring=ZZ, cohomology=False,
(0, 1, 2) and facets {(0, 1), (0, 2), (1, 2)}
sage: Z.cubical_complex()
Cubical complex with 64 vertices and 729 cubes
sage: Z.cubical_complex().homology() == Z.homology()
sage: Z.cubical_complex().homology() == Z.homology() # needs sage.modules
True

Meanwhile, the homology computation used here is quite efficient
and works well even with significantly larger underlying simplicial
complexes::

sage: # needs sage.modules
sage: Z = MomentAngleComplex([[0,1,2,3,4,5], [0,1,2,3,4,6],
....: [0,1,2,3,5,7], [0,1,2,3,6,8,9]])
sage: Z.homology() # long time
Expand Down Expand Up @@ -656,6 +661,7 @@ def cohomology(self, dim=None, base_ring=ZZ, algorithm='pari',
to a product of two 3-spheres (which can be seen by looking at the
output of ``components()``)::

sage: # needs sage.modules
sage: S3 = simplicial_complexes.Sphere(3)
sage: product_of_spheres = S3.product(S3)
sage: Z.cohomology()
Expand Down Expand Up @@ -684,6 +690,7 @@ def betti(self, dim=None):

EXAMPLES::

sage: # needs sage.modules
sage: Z = MomentAngleComplex([[0,1], [1,2], [2,0], [1,2,3]])
sage: Z.betti()
{0: 1, 1: 0, 2: 0, 3: 1, 4: 0, 5: 1, 6: 1, 7: 0}
Expand Down Expand Up @@ -714,6 +721,7 @@ def euler_characteristic(self):

EXAMPLES::

sage: # needs sage.modules
sage: X = SimplicialComplex([[0,1,2,3,4,5], [0,1,2,3,4,6],
....: [0,1,2,3,5,7], [0,1,2,3,6,8,9]])
sage: M = MomentAngleComplex(X)
Expand Down