code
stringlengths
17
6.64M
class Function_frac(BuiltinFunction): def __init__(self): "\n The fractional part function `\\{x\\}`.\n\n ``frac(x)`` is defined as `\\{x\\} = x - \\lfloor x\\rfloor`.\n\n EXAMPLES::\n\n sage: frac(5.4)\n 0.400000000000000\n sage: type(frac(5.4))\n ...
class Function_real_nth_root(BuiltinFunction): '\n Real `n`-th root function `x^\\frac{1}{n}`.\n\n The function assumes positive integer `n` and real number `x`.\n\n EXAMPLES::\n\n sage: real_nth_root(2, 3) # needs sage.symbolic\n 2^(1/3...
class Function_arg(BuiltinFunction): def __init__(self): '\n The argument function for complex numbers.\n\n EXAMPLES::\n\n sage: # needs sage.symbolic\n sage: arg(3+i)\n arctan(1/3)\n sage: arg(-1+i)\n 3/4*pi\n sage: arg(2+2*...
class Function_real_part(GinacFunction): def __init__(self): "\n Returns the real part of the (possibly complex) input.\n\n It is possible to prevent automatic evaluation using the\n ``hold`` parameter::\n\n sage: real_part(I, hold=True) ...
class Function_imag_part(GinacFunction): def __init__(self): "\n Returns the imaginary part of the (possibly complex) input.\n\n It is possible to prevent automatic evaluation using the\n ``hold`` parameter::\n\n sage: imag_part(I, hold=True) ...
class Function_conjugate(GinacFunction): def __init__(self): "\n Returns the complex conjugate of the input.\n\n It is possible to prevent automatic evaluation using the\n ``hold`` parameter::\n\n sage: conjugate(I, hold=True) ...
class Function_factorial(GinacFunction): def __init__(self): "\n Returns the factorial of `n`.\n\n INPUT:\n\n - ``n`` -- a non-negative integer, a complex number (except negative\n integers) or any symbolic expression\n\n\n OUTPUT: an integer or symbolic expression\...
class Function_binomial(GinacFunction): def __init__(self): "\n Return the binomial coefficient\n\n .. MATH::\n\n \\binom{x}{m} = x (x-1) \\cdots (x-m+1) / m!\n\n\n which is defined for `m \\in \\ZZ` and any\n `x`. We extend this definition to include cases when\n ...
class Function_sum(BuiltinFunction): '\n Placeholder symbolic sum function that is only accessible internally.\n\n EXAMPLES::\n\n sage: from sage.functions.other import symbolic_sum as ssum\n sage: r = ssum(x, x, 1, 10); r # needs sage.symbolic\...
class Function_prod(BuiltinFunction): '\n Placeholder symbolic product function that is only accessible internally.\n\n EXAMPLES::\n\n sage: from sage.functions.other import symbolic_product as sprod\n sage: r = sprod(x, x, 1, 10); r # needs sage...
class Function_limit(BuiltinFunction): "\n Placeholder symbolic limit function that is only accessible internally.\n\n This function is called to create formal wrappers of limits that\n Maxima can't compute::\n\n sage: a = lim(exp(x^2)*(1-erf(x)), x=infinity); a # nee...
class Function_cases(GinacFunction): "\n Formal function holding ``(condition, expression)`` pairs.\n\n Numbers are considered conditions with zero being ``False``.\n A true condition marks a default value. The function is not\n evaluated as long as it contains a relation that cannot be\n decided b...
class Function_crootof(BuiltinFunction): '\n Formal function holding ``(polynomial, index)`` pairs.\n\n The expression evaluates to a floating point value that is an\n approximation to a specific complex root of the polynomial. The\n ordering is fixed so you always get the same root.\n\n The functi...
class Function_elementof(BuiltinFunction): '\n Formal set membership function that is only accessible internally.\n\n This function is called to express a set membership statement,\n usually as part of a solution set returned by :func:`solve`.\n See :class:`sage.sets.set.Set` and :class:`sage.sets.rea...
class PiecewiseFunction(BuiltinFunction): def __init__(self): "\n Piecewise function\n\n EXAMPLES::\n\n sage: var('x, y')\n (x, y)\n sage: f = piecewise([((0,1), x^2*y), ([-1,0], -x*y^2)], var=x); f\n piecewise(x|-->x^2*y on (0, 1), x|-->-x*y^2 o...
class SphericalHarmonic(BuiltinFunction): "\n Returns the spherical harmonic function `Y_n^m(\\theta, \\varphi)`.\n\n For integers `n > -1`, `|m| \\leq n`, simplification is done automatically.\n Numeric evaluation is supported for complex `n` and `m`.\n\n EXAMPLES::\n\n sage: # needs sage.symb...
def elliptic_j(z, prec=53): '\n Returns the elliptic modular `j`-function evaluated at `z`.\n\n INPUT:\n\n - ``z`` (complex) -- a complex number with positive imaginary part.\n\n - ``prec`` (default: 53) -- precision in bits for the complex field.\n\n OUTPUT:\n\n (complex) The value of `j(z)`.\n...
class EllipticE(BuiltinFunction): '\n Return the incomplete elliptic integral of the\n second kind:\n\n .. MATH::\n\n E(\\varphi\\,|\\,m)=\\int_0^\\varphi \\sqrt{1 - m\\sin(x)^2}\\, dx.\n\n EXAMPLES::\n\n sage: z = var("z") # n...
class EllipticEC(BuiltinFunction): '\n Return the complete elliptic integral of the second kind:\n\n .. MATH::\n\n E(m)=\\int_0^{\\pi/2} \\sqrt{1 - m\\sin(x)^2}\\, dx.\n\n EXAMPLES::\n\n sage: elliptic_ec(0.1) # needs mpmath\n ...
class EllipticEU(BuiltinFunction): "\n Return Jacobi's form of the incomplete elliptic integral of the second kind:\n\n .. MATH::\n\n E(u,m)=\n \\int_0^u \\mathrm{dn}(x,m)^2\\, dx = \\int_0^\\tau\n \\frac{\\sqrt{1-m x^2}}{\\sqrt{1-x^2}}\\, dx.\n\n where `\\tau = \\mathrm{sn}(u, m)`.\...
def elliptic_eu_f(u, m): "\n Internal function for numeric evaluation of ``elliptic_eu``, defined as\n `E\\left(\\operatorname{am}(u, m)|m\\right)`, where `E` is the incomplete\n elliptic integral of the second kind and `\\operatorname{am}` is the Jacobi\n amplitude function.\n\n EXAMPLES::\n\n ...
class EllipticF(BuiltinFunction): '\n Return the incomplete elliptic integral of the first kind.\n\n .. MATH::\n\n F(\\varphi\\,|\\,m)=\\int_0^\\varphi \\frac{dx}{\\sqrt{1 - m\\sin(x)^2}},\n\n Taking `\\varphi = \\pi/2` gives\n :func:`elliptic_kc()<sage.functions.special.EllipticKC>`.\n\n EX...
class EllipticKC(BuiltinFunction): '\n Return the complete elliptic integral of the first kind:\n\n .. MATH::\n\n K(m)=\\int_0^{\\pi/2} \\frac{dx}{\\sqrt{1 - m\\sin(x)^2}}.\n\n EXAMPLES::\n\n sage: elliptic_kc(0.5) # needs mpmath\n ...
class EllipticPi(BuiltinFunction): '\n Return the incomplete elliptic integral of the third kind:\n\n .. MATH::\n\n \\Pi(n, t, m) = \\int_0^t \\frac{dx}{(1 - n \\sin(x)^2)\\sqrt{1 - m \\sin(x)^2}}.\n\n INPUT:\n\n - ``n`` -- a real number, called the "characteristic"\n\n - ``t`` -- a real num...
class SpikeFunction(): '\n Base class for spike functions.\n\n INPUT:\n\n - ``v`` -- list of pairs (x, height)\n\n - ``eps`` -- parameter that determines approximation to a true spike\n\n OUTPUT:\n\n a function with spikes at each point ``x`` in ``v`` with the given height.\n\n EXAMPLES::\n...
class Function_zeta(GinacFunction): def __init__(self): "\n Riemann zeta function at s with s a real or complex number.\n\n INPUT:\n\n - ``s`` - real or complex number\n\n If s is a real number, the computation is done using the MPFR\n library. When the input is not re...
class Function_stieltjes(GinacFunction): def __init__(self): "\n Stieltjes constant of index ``n``.\n\n ``stieltjes(0)`` is identical to the Euler-Mascheroni constant\n (:class:`sage.symbolic.constants.EulerGamma`). The Stieltjes\n constants are used in the series expansions o...
class Function_HurwitzZeta(BuiltinFunction): def __init__(self): '\n TESTS::\n\n sage: latex(hurwitz_zeta(x, 2)) # needs sage.symbolic\n \\zeta\\left(x, 2\\right)\n sage: hurwitz_zeta(x, 2)._sympy_() ...
def hurwitz_zeta(s, x, **kwargs): "\n The Hurwitz zeta function `\\zeta(s, x)`, where `s` and `x` are complex.\n\n The Hurwitz zeta function is one of the many zeta functions. It\n is defined as\n\n .. MATH::\n\n \\zeta(s, x) = \\sum_{k=0}^{\\infty} (k + x)^{-s}.\n\n\n When `x = 1`, thi...
class Function_zetaderiv(GinacFunction): def __init__(self): "\n Derivatives of the Riemann zeta function.\n\n EXAMPLES::\n\n sage: # needs sage.symbolic\n sage: zetaderiv(1, x)\n zetaderiv(1, x)\n sage: zetaderiv(1, x).diff(x)\n zetade...
def zeta_symmetric(s): '\n Completed function `\\xi(s)` that satisfies\n `\\xi(s) = \\xi(1-s)` and has zeros at the same points as the\n Riemann zeta function.\n\n INPUT:\n\n\n - ``s`` - real or complex number\n\n\n If s is a real number the computation is done using the MPFR\n library. When...
class DickmanRho(BuiltinFunction): '\n Dickman\'s function is the continuous function satisfying the\n differential equation\n\n .. MATH::\n\n x \\rho\'(x) + \\rho(x-1) = 0\n\n with initial conditions `\\rho(x)=1` for\n `0 \\le x \\le 1`. It is useful in estimating the frequency\n of smo...
class Function_sin(GinacFunction): def __init__(self): "\n The sine function.\n\n EXAMPLES::\n\n sage: # needs sage.symbolic\n sage: sin(0)\n 0\n sage: sin(x).subs(x==0)\n 0\n sage: sin(2).n(100)\n 0.90929742682568...
class Function_cos(GinacFunction): def __init__(self): "\n The cosine function.\n\n EXAMPLES::\n\n sage: # needs sage.symbolic\n sage: cos(pi)\n -1\n sage: cos(x).subs(x==pi)\n -1\n sage: cos(2).n(100)\n -0.4161468...
class Function_tan(GinacFunction): def __init__(self): "\n The tangent function.\n\n EXAMPLES::\n\n sage: tan(3.1415)\n -0.0000926535900581913\n sage: tan(3.1415/4)\n 0.999953674278156\n\n sage: # needs sage.symbolic\n sage: ...
class Function_cot(GinacFunction): def __init__(self): "\n The cotangent function.\n\n EXAMPLES::\n\n sage: # needs sage.symbolic\n sage: cot(pi/4)\n 1\n sage: RR(cot(pi/4))\n 1.00000000000000\n sage: cot(1/2)\n co...
class Function_sec(GinacFunction): def __init__(self): '\n The secant function.\n\n EXAMPLES::\n\n sage: # needs sage.symbolic\n sage: sec(pi/4)\n sqrt(2)\n sage: sec(x).subs(x==pi/4)\n sqrt(2)\n sage: sec(pi/7)\n ...
class Function_csc(GinacFunction): def __init__(self): '\n The cosecant function.\n\n EXAMPLES::\n\n sage: # needs sage.symbolic\n sage: csc(pi/4)\n sqrt(2)\n sage: csc(x).subs(x==pi/4)\n sqrt(2)\n sage: csc(pi/7)\n ...
class Function_arcsin(GinacFunction): def __init__(self): "\n The arcsine function.\n\n EXAMPLES::\n\n sage: arcsin(0.5)\n 0.523598775598299\n sage: arcsin(1/2) # needs sage.symbolic\n 1/6*...
class Function_arccos(GinacFunction): def __init__(self): "\n The arccosine function.\n\n EXAMPLES::\n\n sage: arccos(0.5)\n 1.04719755119660\n sage: arccos(1/2) # needs sage.symbolic\n 1/3...
class Function_arctan(GinacFunction): def __init__(self): "\n The arctangent function.\n\n EXAMPLES::\n\n sage: # needs sage.symbolic\n sage: arctan(1/2)\n arctan(1/2)\n sage: RDF(arctan(1/2)) # rel tol 1e-15\n 0.46364760900080615\n ...
class Function_arccot(GinacFunction): def __init__(self): '\n The arccotangent function.\n\n EXAMPLES::\n\n sage: # needs sage.symbolic\n sage: arccot(1/2)\n arccot(1/2)\n sage: RDF(arccot(1/2)) # abs tol 2e-16\n 1.1071487177940906\n ...
class Function_arccsc(GinacFunction): def __init__(self): '\n The arccosecant function.\n\n EXAMPLES::\n\n sage: # needs sage.symbolic\n sage: arccsc(2)\n arccsc(2)\n sage: RDF(arccsc(2)) # rel tol 1e-15\n 0.5235987755982988\n ...
class Function_arcsec(GinacFunction): def __init__(self): '\n The arcsecant function.\n\n EXAMPLES::\n\n sage: # needs sage.symbolic\n sage: arcsec(2)\n arcsec(2)\n sage: arcsec(2.0)\n 1.04719755119660\n sage: arcsec(2).n(100...
class Function_arctan2(GinacFunction): def __init__(self): "\n The modified arctangent function.\n\n Returns the arc tangent (measured in radians) of `y/x`, where\n unlike ``arctan(y/x)``, the signs of both ``x`` and ``y`` are\n considered. In particular, this function measur...
def _calc_factlist(nn): '\n Return a list of precomputed factorials in order to massively\n accelerate future calculations of the various coefficients.\n\n INPUT:\n\n - ``nn`` -- integer, highest factorial to be computed\n\n OUTPUT:\n\n list of integers -- the list of precomputed factorials\n\n ...
def wigner_3j(j_1, j_2, j_3, m_1, m_2, m_3, prec=None): '\n Return the Wigner 3-`j` symbol `\\begin{pmatrix} j_1 & j_2 & j_3 \\\\ m_1 & m_2 & m_3 \\end{pmatrix}`.\n\n INPUT:\n\n - ``j_1``, ``j_2``, ``j_3``, ``m_1``, ``m_2``, ``m_3`` -- integer or half integer\n\n - ``prec`` -- precision, default: ``...
def clebsch_gordan(j_1, j_2, j_3, m_1, m_2, m_3, prec=None): '\n Return the Clebsch-Gordan coefficient\n `\\langle j_1 m_1 \\; j_2 m_2 | j_3 m_3 \\rangle`.\n\n The reference for this function is [Ed1974]_.\n\n INPUT:\n\n - ``j_1``, ``j_2``, ``j_3``, ``m_1``, ``m_2``, ``m_3`` -- integer or half int...
def _big_delta_coeff(aa, bb, cc, prec=None): '\n Return the Delta coefficient of the 3 angular momenta for Racah symbols.\n\n This also checks that the differences are of integer value.\n\n INPUT:\n\n - ``aa`` -- first angular momentum, integer or half integer\n\n - ``bb`` -- second angular momen...
def racah(aa, bb, cc, dd, ee, ff, prec=None): '\n Return the Racah symbol `W(aa,bb,cc,dd;ee,ff)`.\n\n INPUT:\n\n - ``aa``, ..., ``ff`` -- integer or half integer\n\n - ``prec`` -- precision, default: ``None``. Providing a precision can\n drastically speed up the calculation.\n\n OUTPUT:\n\n...
def wigner_6j(j_1, j_2, j_3, j_4, j_5, j_6, prec=None): "\n Return the Wigner 6-`j` symbol `\\begin{Bmatrix} j_1 & j_2 & j_3 \\\\ j_4 & j_5 & j_6 \\end{Bmatrix}`.\n\n INPUT:\n\n - ``j_1``, ..., ``j_6`` -- integer or half integer\n\n - ``prec`` -- precision, default: ``None``. Providing a precision c...
def wigner_9j(j_1, j_2, j_3, j_4, j_5, j_6, j_7, j_8, j_9, prec=None): '\n Return the Wigner 9-`j` symbol\n `\\begin{Bmatrix} j_1 & j_2 & j_3 \\\\ j_4 & j_5 & j_6 \\\\ j_7 & j_8 & j_9 \\end{Bmatrix}`.\n\n INPUT:\n\n - ``j_1``, ..., ``j_9`` -- integer or half integer\n\n - ``prec`` -- precision, d...
def gaunt(l_1, l_2, l_3, m_1, m_2, m_3, prec=None): '\n Return the Gaunt coefficient.\n\n The Gaunt coefficient is defined as the integral over three\n spherical harmonics:\n\n .. MATH::\n\n Y(l_1,l_2,l_3,m_1,m_2,m_3) \\hspace{12em} \\\\\n =\\int Y_{l_1,m_1}(\\Omega) \\\n Y_{l_2,...
def PrisonersDilemma(R=(- 2), P=(- 4), S=(- 5), T=0): "\n Return a Prisoners dilemma game.\n\n Assume two thieves have been caught by the police\n and separated for questioning.\n If both thieves cooperate and do not divulge any information they will\n each get a short sentence.\n If one defects...
def CoordinationGame(A=10, a=5, B=0, b=0, C=0, c=0, D=5, d=10): '\n Return a 2 by 2 Coordination Game.\n\n A coordination game is a particular type of game where the pure Nash\n equilibrium is for the players to pick the same strategies [Web2007]_.\n\n In general these are represented as a normal form...
def BattleOfTheSexes(): '\n Return a Battle of the Sexes game.\n\n Consider two payers: Amy and Bob.\n Amy prefers to play video games and Bob prefers to\n watch a movie. They both however want to spend their evening\n together.\n This can be modeled as a normal form game using the following two...
def StagHunt(): '\n Return a Stag Hunt game.\n\n Assume two friends go out on a hunt. Each can individually choose to hunt\n a stag or hunt a hare. Each player must choose an action without knowing\n the choice of the other. If an individual hunts a stag, he must have the\n cooperation of his partn...
def AntiCoordinationGame(A=3, a=3, B=5, b=1, C=1, c=5, D=0, d=0): '\n Return a 2 by 2 AntiCoordination Game.\n\n An anti coordination game is a particular type of game where the pure Nash\n equilibria is for the players to pick different strategies.\n\n In general these are represented as a normal for...
def HawkDove(v=2, c=3): '\n Return a Hawk Dove game.\n\n Suppose two birds of prey must share a limited resource `v`.\n The birds can act like a hawk or a dove.\n\n - If a dove meets a hawk, the hawk takes the resources.\n - If two doves meet they share the resources.\n - If two hawks meet, one ...
def Pigs(): "\n Return a Pigs game.\n\n Consider two pigs.\n One dominant pig and one subservient pig.\n These pigs share a pen.\n There is a lever in the pen that delivers 6 units of food but if either pig\n pushes the lever it will take them a little while to get to the food as well\n as co...
def MatchingPennies(): "\n Return a Matching Pennies game.\n\n Consider two players who can choose to display a coin either Heads\n facing up or Tails facing up.\n If both players show the same face then player 1 wins,\n if not then player 2 wins.\n\n This can be modeled as a zero sum normal for...
def RPS(): '\n Return a Rock-Paper-Scissors game.\n\n Rock-Paper-Scissors is a zero sum game usually played between two\n players where each player simultaneously forms one of three\n shapes with an outstretched hand.The game has only three possible outcomes\n other than a tie: a player who decides...
def RPSLS(): "\n Return a Rock-Paper-Scissors-Lizard-Spock game.\n\n `Rock-Paper-Scissors-Lizard-Spock\n <http://www.samkass.com/theories/RPSSL.html>`_ is an extension of\n Rock-Paper-Scissors.\n It is a zero sum game usually played between two\n players where each player simultaneously forms on...
def Chicken(A=0, a=0, B=1, b=(- 1), C=(- 1), c=1, D=(- 10), d=(- 10)): '\n Return a Chicken game.\n\n Consider two drivers locked in a fierce battle for pride. They drive\n towards a cliff and the winner is declared as the last one to swerve.\n If neither player swerves they will both fall off the cli...
def TravellersDilemma(max_value=10): "\n Return a Travellers dilemma game.\n\n An airline loses two suitcases belonging to two different travelers. Both\n suitcases happen to be identical and contain identical antiques. An\n airline manager tasked to settle the claims of both travelers explains\n t...
class CooperativeGame(SageObject): '\n An object representing a co-operative game. Primarily used to compute the\n Shapley value, but can also provide other information.\n\n INPUT:\n\n - ``characteristic_function`` -- a dictionary containing all possible\n sets of players:\n\n * key - each s...
class MatchingGame(SageObject): "\n A matching game.\n\n A matching game (also called a stable matching problem) models a situation\n in a population of `N` suitors and `N` reviewers. Suitors and reviewers\n rank their preferences and attempt to find a match.\n\n Formally, a matching game of size `...
class Player(): '\n A class to act as a data holder for the players used of the\n matching games.\n\n These instances are used when initiating players and to keep track of\n whether or not partners have a preference.\n ' def __init__(self, name): '\n TESTS::\n\n sage:...
class NormalFormGame(SageObject, MutableMapping): '\n An object representing a Normal Form Game. Primarily used to compute the\n Nash Equilibria.\n\n INPUT:\n\n - ``generator`` -- can be a list of 2 matrices, a single matrix or left\n blank\n\n ' def __init__(self, generator=None): ...
class _Player(): def __init__(self, num_strategies): '\n TESTS::\n\n sage: from sage.game_theory.normal_form_game import _Player\n sage: p = _Player(5)\n sage: p.num_strategies\n 5\n ' self.num_strategies = num_strategies def add_stra...
class Parser(): "\n A class for parsing the outputs of different algorithms called in other\n software packages.\n\n Two parsers are included, one for the ``'lrs'`` algorithm and another for\n the ``'LCP'`` algorithm.\n " def __init__(self, raw_string): "\n Initialise a Parser i...
def view_list(L): '\n This provides a printout of the lines, crosses and squares\n of the MINIMOG, as in Curtis\' paper [Cu1984]_.\n\n EXAMPLES::\n\n sage: from sage.games.hexad import *\n sage: M = Minimog(type="shuffle")\n sage: view_list(M.line[1])\n <BLANKLINE>\n [0...
def picture_set(A, L) -> set: '\n This is needed in the :meth:`Minimog.find_hexad` function below.\n\n EXAMPLES::\n\n sage: from sage.games.hexad import *\n sage: M = Minimog(type="shuffle")\n sage: picture_set(M.picture00, M.cross[2])\n {5, 7, 8, 9, 10}\n sage: picture_se...
class Minimog(): '\n This implements the Conway/Curtis minimog idea for describing\n the Steiner triple system `S(5, 6, 12)`.\n\n EXAMPLES::\n\n sage: from sage.games.hexad import *\n sage: Minimog(type="shuffle")\n Minimog of type shuffle\n sage: M = Minimog(type = "modulo11"...
def show_pentaminos(box=(5, 8, 2)): '\n Show the 17 3-D pentaminos included in the game and the `5 \\times 8\n \\times 2` box where 16 of them must fit.\n\n INPUT:\n\n - ``box`` -- tuple of size three (optional, default: ``(5,8,2)``),\n size of the box\n\n OUTPUT:\n\n 3D Graphic object\n\n ...
class QuantuminoState(SageObject): '\n A state of the Quantumino puzzle.\n\n Used to represent a solution or a partial solution of the Quantumino\n puzzle.\n\n INPUT:\n\n - ``pentos`` - list of 16 3d pentamino representing the (partial)\n solution\n - ``aside`` - 3d polyomino, the unused 3D...
class QuantuminoSolver(SageObject): '\n Return the Quantumino solver for the given box where one of the\n pentamino is put aside.\n\n INPUT:\n\n - ``aside`` - integer, from 0 to 16, the aside pentamino\n - ``box`` - tuple of size three (optional, default: ``(5,8,2)``),\n size of the box\n\n ...
def sudoku(m): "\n Solves Sudoku puzzles described by matrices.\n\n INPUT:\n\n - ``m`` - a square Sage matrix over `\\ZZ`, where zeros are blank entries\n\n OUTPUT:\n\n A Sage matrix over `\\ZZ` containing the first solution found,\n otherwise ``None``.\n\n This function matches the behavior ...
class Sudoku(SageObject): "\n An object representing a Sudoku puzzle. Primarily the purpose is to\n solve the puzzle, but conversions between formats are also provided.\n\n INPUT:\n\n - puzzle -- the first argument can take one of three forms\n * list - a Python list with elements of the puzzl...
def is_Cone(x): '\n Check if ``x`` is a cone.\n\n INPUT:\n\n - ``x`` -- anything.\n\n OUTPUT:\n\n - ``True`` if ``x`` is a cone and ``False`` otherwise.\n\n EXAMPLES::\n\n sage: from sage.geometry.cone import is_Cone\n sage: is_Cone(1)\n False\n sage: quadrant = Cone(...
def Cone(rays, lattice=None, check=True, normalize=True): '\n Construct a (not necessarily strictly) convex rational polyhedral cone.\n\n INPUT:\n\n - ``rays`` -- a list of rays. Each ray should be given as a list\n or a vector convertible to the rational extension of the given\n ``lattice``. M...
def _Cone_from_PPL(cone, lattice, original_rays=None): '\n Construct a cone from a :class:`~ppl.polyhedron.Polyhedron`.\n\n This is a private function and not intended to be exposed to the\n end user. It is used internally by :func:`Cone` and in\n :meth:`ConvexRationalPolyhedralCone.intersection`.\n\n...
def _ambient_space_point(body, data): '\n Try to convert ``data`` to a point of the ambient space of ``body``.\n\n INPUT:\n\n - ``body`` -- a cone, fan, or lattice polytope with ``lattice()`` method\n\n - ``data`` -- anything\n\n OUTPUT:\n\n An integral, rational, real algebraic, or numeric poin...
def integral_length(v): '\n Compute the integral length of a given rational vector.\n\n INPUT:\n\n - ``v`` -- any object which can be converted to a list of rationals\n\n OUTPUT:\n\n Rational number `r`` such that ``v = r * u``, where ``u`` is the\n primitive integral vector in the direction of ...
def normalize_rays(rays, lattice): '\n Normalize a list of rational rays: make them primitive and immutable.\n\n INPUT:\n\n - ``rays`` -- list of rays which can be converted to the rational\n extension of ``lattice``;\n\n - ``lattice`` -- :class:`ToricLattice\n <sage.geometry.toric_lattice.T...
@richcmp_method class IntegralRayCollection(SageObject, Hashable, Iterable): '\n Create a collection of integral rays.\n\n .. WARNING::\n\n No correctness check or normalization is performed on the input data.\n This class is designed for internal operations and you probably should\n no...
def classify_cone_2d(ray0, ray1, check=True): '\n Return `(d,k)` classifying the lattice cone spanned by the two rays.\n\n INPUT:\n\n - ``ray0``, ``ray1`` -- two primitive integer vectors. The\n generators of the two rays generating the two-dimensional cone.\n\n - ``check`` -- boolean (default: `...
@richcmp_method class ConvexRationalPolyhedralCone(IntegralRayCollection, Container, ConvexSet_closed, sage.geometry.abc.ConvexRationalPolyhedralCone): '\n Create a convex rational polyhedral cone.\n\n .. WARNING::\n\n This class does not perform any checks of correctness of input nor\n does i...
def random_cone(lattice=None, min_ambient_dim=0, max_ambient_dim=None, min_rays=0, max_rays=None, strictly_convex=None, solid=None): '\n Generate a random convex rational polyhedral cone.\n\n Lower and upper bounds may be provided for both the dimension of the\n ambient space and the number of generating...
def _preprocess_args(ambient_dim, lattice): '\n Preprocess arguments for cone-constructing functions.\n\n Each cone-constructing function in this module performs some\n preprocessing on its ``ambient_dim`` and ``lattice`` arguments to\n ensure that they both wind up defined and compatible with one\n ...
def nonnegative_orthant(ambient_dim=None, lattice=None): "\n The nonnegative orthant in ``ambient_dim`` dimensions, or living\n in ``lattice``.\n\n The nonnegative orthant consists of all componentwise-nonnegative\n vectors. It is the convex-conic hull of the standard basis.\n\n INPUT:\n\n - ``a...
def rearrangement(p, ambient_dim=None, lattice=None): '\n The rearrangement cone of order ``p`` in ``ambient_dim``\n dimensions, or living in ``lattice``.\n\n The rearrangement cone of order ``p`` in ``ambient_dim``\n dimensions consists of all vectors of length ``ambient_dim``\n whose smallest ``p...
def schur(ambient_dim=None, lattice=None): '\n The Schur cone in ``ambient_dim`` dimensions, or living\n in ``lattice``.\n\n The Schur cone in `n` dimensions induces the majorization ordering\n on the ambient space. If `\\left\\{e_{1}, e_{2}, \\ldots,\n e_{n}\\right\\}` is the standard basis for th...
def trivial(ambient_dim=None, lattice=None): "\n The trivial cone with no nonzero generators in ``ambient_dim``\n dimensions, or living in ``lattice``.\n\n INPUT:\n\n - ``ambient_dim`` -- a nonnegative integer (default: ``None``); the\n dimension of the ambient space\n\n - ``lattice`` -- a tor...
@dataclass class AffineHullProjectionData(): image: Any = None projection_linear_map: Any = None projection_translation: Any = None section_linear_map: Any = None section_translation: Any = None
class ConvexSet_base(SageObject, Set_base): '\n Abstract base class for convex sets.\n ' def is_empty(self): '\n Test whether ``self`` is the empty set.\n\n OUTPUT:\n\n Boolean.\n\n EXAMPLES::\n\n sage: p = LatticePolytope([], lattice=ToricLattice(3).dual(...
class ConvexSet_closed(ConvexSet_base): '\n Abstract base class for closed convex sets.\n ' def is_closed(self): '\n Return whether ``self`` is closed.\n\n OUTPUT:\n\n Boolean.\n\n EXAMPLES::\n\n sage: hcube = polytopes.hypercube(5)\n sage: hcub...
class ConvexSet_compact(ConvexSet_closed): '\n Abstract base class for compact convex sets.\n ' def is_universe(self): '\n Return whether ``self`` is the whole ambient space\n\n OUTPUT:\n\n Boolean.\n\n EXAMPLES::\n\n sage: cross3 = lattice_polytope.cross_...
class ConvexSet_relatively_open(ConvexSet_base): '\n Abstract base class for relatively open convex sets.\n ' def is_relatively_open(self): '\n Return whether ``self`` is relatively open.\n\n OUTPUT:\n\n Boolean.\n\n EXAMPLES::\n\n sage: segment = Polyhedr...
class ConvexSet_open(ConvexSet_relatively_open): '\n Abstract base class for open convex sets.\n ' def is_open(self): '\n Return whether ``self`` is open.\n\n OUTPUT:\n\n Boolean.\n\n EXAMPLES::\n\n sage: from sage.geometry.convex_set import ConvexSet_open...