code
stringlengths
17
6.64M
def Manifold(dim: int, name: Optional[str], latex_name: Optional[str]=None, field: str='real', structure: Optional[str]=None, start_index: int=0, **extra_kwds) -> Union[(TopologicalManifold, DifferentiableManifold)]: '\n Construct a manifold of a given type over a topological field.\n\n Given a topological ...
class TopologicalManifoldHomset(UniqueRepresentation, Homset): "\n Set of continuous maps between two topological manifolds.\n\n Given two topological manifolds `M` and `N` over a topological field `K`,\n the class :class:`TopologicalManifoldHomset` implements the set\n `\\mathrm{Hom}(M, N)` of morphi...
def grad(scalar): "\n Gradient operator.\n\n The *gradient* of a scalar field `f` on a pseudo-Riemannian manifold\n `(M,g)` is the vector field `\\mathrm{grad}\\, f` whose components in any\n coordinate frame are\n\n .. MATH::\n\n (\\mathrm{grad}\\, f)^i = g^{ij} \\frac{\\partial F}{\\partia...
def div(tensor): "\n Divergence operator.\n\n Let `t` be a tensor field of type `(k,0)` with `k\\geq 1` on a\n pseudo-Riemannian manifold `(M, g)`. The *divergence* of `t` is the tensor\n field of type `(k-1,0)` defined by\n\n .. MATH::\n\n (\\mathrm{div}\\, t)^{a_1\\ldots a_{k-1}} =\n ...
def curl(vector): "\n Curl operator.\n\n The *curl* of a vector field `v` on an orientable pseudo-Riemannian\n manifold `(M,g)` of dimension 3 is the vector field defined by\n\n .. MATH::\n\n \\mathrm{curl}\\, v = (*(\\mathrm{d} v^\\flat))^\\sharp\n\n where `v^\\flat` is the 1-form associate...
def laplacian(field): "\n Laplace-Beltrami operator.\n\n The *Laplace-Beltrami operator* on a pseudo-Riemannian manifold `(M,g)`\n is the operator\n\n .. MATH::\n\n \\Delta = \\nabla_i \\nabla^i = g^{ij} \\nabla_i \\nabla_j\n\n where `\\nabla` is the Levi-Civita connection of the metric `g`...
def dalembertian(field): "\n d'Alembert operator.\n\n The *d'Alembert operator* or *d'Alembertian* on a Lorentzian manifold\n `(M,g)` is nothing but the Laplace-Beltrami operator:\n\n .. MATH::\n\n \\Box = \\nabla_i \\nabla^i = g^{ij} \\nabla_i \\nabla_j\n\n where `\\nabla` is the Levi-Civi...
class ManifoldPoint(Element): "\n Point of a topological manifold.\n\n This is a Sage *element* class, the corresponding *parent* class\n being :class:`~sage.manifolds.manifold.TopologicalManifold`\n or :class:`~sage.manifolds.subset.ManifoldSubset`.\n\n INPUT:\n\n - ``parent`` -- the manifold s...
class ScalarField(CommutativeAlgebraElement, ModuleElementWithMutability): "\n Scalar field on a topological manifold.\n\n Given a topological manifold `M` over a topological field `K` (in most\n applications, `K = \\RR` or `K = \\CC`), a *scalar field on* `M` is a\n continuous map\n\n .. MATH::\n\...
class ScalarFieldAlgebra(UniqueRepresentation, Parent): "\n Commutative algebra of scalar fields on a topological manifold.\n\n If `M` is a topological manifold over a topological field `K`, the\n commutative algebra of scalar fields on `M` is the set `C^0(M)` of all\n continuous maps `M \\to K`. The ...
class SectionModule(UniqueRepresentation, Parent): "\n Module of sections over a vector bundle `E \\to M` of class `C^k` on a domain\n `U \\in M`.\n\n The *section module* `C^k(U;E)` is the set of all `C^k`-maps, called\n *sections*, of type\n\n .. MATH::\n\n s: U \\longrightarrow E\n\n s...
class SectionFreeModule(FiniteRankFreeModule): "\n Free module of sections over a vector bundle `E \\to M` of class `C^k` on a\n domain `U \\in M` which admits a trivialization or local frame.\n\n The *section module* `C^k(U;E)` is the set of all `C^k`-maps, called\n *sections*, of type\n\n .. MATH...
class TopologicalStructure(Singleton): '\n The structure of a topological manifold over a general topological field.\n ' chart = Chart name = 'topological' scalar_field_algebra = ScalarFieldAlgebra homset = TopologicalManifoldHomset def subcategory(self, cat): '\n Return ...
class RealTopologicalStructure(Singleton): '\n The structure of a topological manifold over `\\RR`.\n ' chart = RealChart name = 'topological' scalar_field_algebra = ScalarFieldAlgebra homset = TopologicalManifoldHomset def subcategory(self, cat): '\n Return the subcatego...
class DifferentialStructure(Singleton): '\n The structure of a differentiable manifold over a general topological\n field.\n ' chart = DiffChart name = 'differentiable' scalar_field_algebra = DiffScalarFieldAlgebra homset = DifferentiableManifoldHomset def subcategory(self, cat): ...
class RealDifferentialStructure(Singleton): '\n The structure of a differentiable manifold over `\\RR`.\n ' chart = RealDiffChart name = 'differentiable' scalar_field_algebra = DiffScalarFieldAlgebra homset = DifferentiableManifoldHomset def subcategory(self, cat): '\n Re...
class PseudoRiemannianStructure(Singleton): '\n The structure of a pseudo-Riemannian manifold.\n ' chart = RealDiffChart name = 'pseudo-Riemannian' scalar_field_algebra = DiffScalarFieldAlgebra homset = DifferentiableManifoldHomset def subcategory(self, cat): '\n Return t...
class RiemannianStructure(Singleton): '\n The structure of a Riemannian manifold.\n ' chart = RealDiffChart name = 'Riemannian' scalar_field_algebra = DiffScalarFieldAlgebra homset = DifferentiableManifoldHomset def subcategory(self, cat): '\n Return the subcategory of ``...
class LorentzianStructure(Singleton): '\n The structure of a Lorentzian manifold.\n ' chart = RealDiffChart name = 'Lorentzian' scalar_field_algebra = DiffScalarFieldAlgebra homset = DifferentiableManifoldHomset def subcategory(self, cat): '\n Return the subcategory of ``...
class DegenerateStructure(Singleton): '\n The structure of a degenerate manifold.\n ' chart = RealDiffChart name = 'degenerate_metric' scalar_field_algebra = DiffScalarFieldAlgebra homset = DifferentiableManifoldHomset def subcategory(self, cat): '\n Return the subcategor...
class ManifoldSubset(UniqueRepresentation, Parent): "\n Subset of a topological manifold.\n\n The class :class:`ManifoldSubset` inherits from the generic\n class :class:`~sage.structure.parent.Parent`.\n The corresponding element class is\n :class:`~sage.manifolds.point.ManifoldPoint`.\n\n Note ...
class ManifoldSubsetClosure(ManifoldSubset): "\n Topological closure of a manifold subset in the topology of the manifold.\n\n INPUT:\n\n - ``subset`` -- a :class:`~sage.manifolds.subset.ManifoldSubset`\n - ``name`` -- (default: computed from the name of the subset)\n string; name (symbol) given ...
class ManifoldSubsetPullback(ManifoldSubset): '\n Manifold subset defined as a pullback of a subset under a continuous map.\n\n INPUT:\n\n - ``map`` - an instance of :class:`~sage.manifolds.continuous_map.ContinuousMap`,\n :class:`ScalarField`, or :class:`Chart`\n\n - ``codomain_subset`` - an ins...
class TopologicalSubmanifold(TopologicalManifold): '\n Submanifold of a topological manifold.\n\n Given a topological manifold `M` over a topological field `K`, a\n *topological submanifold of* `M` is defined by a topological manifold `N`\n over the same field `K` of dimension lower than the dimension...
class Trivialization(UniqueRepresentation, SageObject): "\n A local trivialization of a given vector bundle.\n\n Let `\\pi:E \\to M` be a vector bundle of rank `n` and class `C^k` over the\n field `K`\n (see :class:`~sage.manifolds.vector_bundle.TopologicalVectorBundle` or\n :class:`~sage.manifolds...
class TransitionMap(SageObject): "\n Transition map between two trivializations.\n\n Given a vector bundle `\\pi : E \\to M` of class `C^k` and rank `n` over the\n field `K`, and two trivializations\n `\\varphi_U : \\pi^{-1}(U) \\to U \\times K^n` and\n `\\varphi_V : \\pi^{-1}(V) \\to V \\times K^n...
class SimplifySqrtReal(ExpressionTreeWalker): "\n Class for simplifying square roots in the real domain, by walking the\n expression tree.\n\n The end user interface is the function :func:`simplify_sqrt_real`.\n\n INPUT:\n\n - ``ex`` -- a symbolic expression\n\n EXAMPLES:\n\n Let us consider ...
class SimplifyAbsTrig(ExpressionTreeWalker): '\n Class for simplifying absolute values of cosines or sines (in the real\n domain), by walking the expression tree.\n\n The end user interface is the function :func:`simplify_abs_trig`.\n\n INPUT:\n\n - ``ex`` -- a symbolic expression\n\n EXAMPLES:\...
def simplify_sqrt_real(expr): "\n Simplify ``sqrt`` in symbolic expressions in the real domain.\n\n EXAMPLES:\n\n Simplifications of basic expressions::\n\n sage: from sage.manifolds.utilities import simplify_sqrt_real\n sage: simplify_sqrt_real( sqrt(x^2) )\n abs(x)\n sage: a...
def simplify_abs_trig(expr): "\n Simplify ``abs(sin(...))`` and ``abs(cos(...))`` in symbolic expressions.\n\n EXAMPLES::\n\n sage: M = Manifold(3, 'M', structure='topological')\n sage: X.<x,y,z> = M.chart(r'x y:(0,pi) z:(-pi/3,0)')\n sage: X.coord_range()\n x: (-oo, +oo); y: (0,...
def simplify_chain_real(expr): "\n Apply a chain of simplifications to a symbolic expression, assuming the\n real domain.\n\n This is the simplification chain used in calculus involving coordinate\n functions on real manifolds, as implemented in\n :class:`~sage.manifolds.chart_func.ChartFunction`.\...
def simplify_chain_generic(expr): "\n Apply a chain of simplifications to a symbolic expression.\n\n This is the simplification chain used in calculus involving coordinate\n functions on manifolds over fields different from `\\RR`, as implemented in\n :class:`~sage.manifolds.chart_func.ChartFunction`....
def simplify_chain_generic_sympy(expr): "\n Apply a chain of simplifications to a sympy expression.\n\n This is the simplification chain used in calculus involving coordinate\n functions on manifolds over fields different from `\\RR`, as implemented in\n :class:`~sage.manifolds.chart_func.ChartFunctio...
def simplify_chain_real_sympy(expr): "\n Apply a chain of simplifications to a sympy expression, assuming the\n real domain.\n\n This is the simplification chain used in calculus involving coordinate\n functions on real manifolds, as implemented in\n :class:`~sage.manifolds.chart_func.ChartFunction...
class ExpressionNice(Expression): '\n Subclass of :class:`~sage.symbolic.expression.Expression` for a\n "human-friendly" display of partial derivatives and the possibility to\n shorten the display by skipping the arguments of symbolic functions.\n\n INPUT:\n\n - ``ex`` -- symbolic expression\n\n ...
def _list_derivatives(ex, list_d, exponent=0): '\n Function to find the occurrences of ``FDerivativeOperator`` in a symbolic\n expression; inspired by\n http://ask.sagemath.org/question/10256/how-can-extract-different-terms-from-a-symbolic-expression/?answer=26136#post-id-26136\n\n INPUT:\n\n - ``e...
def _list_functions(ex, list_f): '\n Function to find the occurrences of symbolic functions in a symbolic\n expression.\n\n INPUT:\n\n - ``ex`` -- symbolic expression to be analyzed\n\n OUTPUT:\n\n - ``list_f`` -- tuple containing the details of a symbolic function found,\n in the following...
def set_axes_labels(graph, xlabel, ylabel, zlabel, **kwds): "\n Set axes labels for a 3D graphics object ``graph``.\n\n This is a workaround for the lack of axes labels in 3D plots.\n This sets the labels as :func:`~sage.plot.plot3d.shapes2.text3d`\n objects at locations determined from the bounding b...
def exterior_derivative(form): "\n Exterior derivative of a differential form.\n\n INPUT:\n\n - ``form`` -- a differential form; this must an instance of either\n\n * :class:`~sage.manifolds.differentiable.scalarfield.DiffScalarField`\n for a 0-form (scalar field)\n * :class:`~sage.manif...
class TopologicalVectorBundle(CategoryObject, UniqueRepresentation): "\n An instance of this class is a topological vector bundle `E \\to B` over a\n topological field `K`.\n\n INPUT:\n\n - ``rank`` -- positive integer; rank of the vector bundle\n - ``name`` -- string representation given to the to...
class VectorBundleFiber(FiniteRankFreeModule): "\n Fiber of a given vector bundle at a given point.\n\n Let `\\pi: E \\to M` be a vector bundle of rank `n` over the field `K`\n (see :class:`~sage.manifolds.vector_bundle.TopologicalVectorBundle`) and\n `p \\in M`. The fiber `E_p` at `p` is defined via ...
class VectorBundleFiberElement(FiniteRankFreeModuleElement): "\n Vector in a fiber of a vector bundle at the given point.\n\n INPUT:\n\n - parent -- :class:`~sage.manifolds.vector_bundle_fiber.VectorBundleFiber`;\n the fiber to which the vector belongs\n - ``name`` -- (default: ``None``) string; ...
def report(F, title, systems=['sage', 'magma'], **kwds): '\n Run benchmarks with default arguments for each function in the list F.\n\n INPUT:\n\n - ``F`` - a list of callables used for benchmarking\n - ``title`` - a string describing this report\n - ``systems`` - a list of systems (supported entri...
def report_ZZ(**kwds): '\n Reports all the benchmarks for integer matrices and few\n rational matrices.\n\n INPUT:\n\n - ``**kwds`` - passed through to :func:`report`\n\n EXAMPLES::\n\n sage: import sage.matrix.benchmark as b\n sage: print("starting"); import sys; sys.stdout.flush(); ...
def nullspace_ZZ(n=200, min=0, max=(2 ** 32), system='sage'): "\n Nullspace over ZZ:\n Given a n+1 x n matrix over ZZ with random entries\n between min and max, compute the nullspace.\n\n INPUT:\n\n - ``n`` - matrix dimension (default: ``200``)\n - ``min`` - minimal value for entries of matrix (...
def charpoly_ZZ(n=100, min=0, max=9, system='sage'): "\n Characteristic polynomial over ZZ:\n Given a n x n matrix over ZZ with random entries between min and\n max, compute the charpoly.\n\n INPUT:\n\n - ``n`` - matrix dimension (default: ``100``)\n - ``min`` - minimal value for entries of matr...
def rank_ZZ(n=700, min=0, max=9, system='sage'): "\n Rank over ZZ:\n Given a n x (n+10) matrix over ZZ with random entries\n between min and max, compute the rank.\n\n INPUT:\n\n - ``n`` - matrix dimension (default: ``700``)\n - ``min`` - minimal value for entries of matrix (default: ``0``)\n ...
def rank2_ZZ(n=400, min=0, max=(2 ** 64), system='sage'): "\n Rank 2 over ZZ:\n Given a (n + 10) x n matrix over ZZ with random entries\n between min and max, compute the rank.\n\n INPUT:\n\n - ``n`` - matrix dimension (default: ``400``)\n - ``min`` - minimal value for entries of matrix (default...
def smithform_ZZ(n=128, min=0, max=9, system='sage'): "\n Smith Form over ZZ:\n Given a n x n matrix over ZZ with random entries\n between min and max, compute the Smith normal form.\n\n INPUT:\n\n - ``n`` - matrix dimension (default: ``128``)\n - ``min`` - minimal value for entries of matrix (d...
def matrix_multiply_ZZ(n=300, min=(- 9), max=9, system='sage', times=1): "\n Matrix multiplication over ZZ\n Given an n x n matrix A over ZZ with random entries\n between min and max, inclusive, compute A * (A+1).\n\n INPUT:\n\n - ``n`` - matrix dimension (default: ``300``)\n - ``min`` - minimal...
def matrix_add_ZZ(n=200, min=(- 9), max=9, system='sage', times=50): "\n Matrix addition over ZZ\n Given an n x n matrix A and B over ZZ with random entries between\n ``min`` and ``max``, inclusive, compute A + B ``times`` times.\n\n INPUT:\n\n - ``n`` - matrix dimension (default: ``200``)\n - `...
def matrix_add_ZZ_2(n=200, bits=16, system='sage', times=50): "\n Matrix addition over ZZ.\n Given an n x n matrix A and B over ZZ with random ``bits``-bit\n entries, compute A + B.\n\n INPUT:\n\n - ``n`` - matrix dimension (default: ``200``)\n - ``bits`` - bitsize of entries\n - ``system`` -...
def det_ZZ(n=200, min=1, max=100, system='sage'): "\n Dense integer determinant over ZZ.\n Given an n x n matrix A over ZZ with random entries\n between min and max, inclusive, compute det(A).\n\n INPUT:\n\n - ``n`` - matrix dimension (default: ``200``)\n - ``min`` - minimal value for entries of...
def det_QQ(n=300, num_bound=10, den_bound=10, system='sage'): "\n Dense rational determinant over QQ.\n Given an n x n matrix A over QQ with random entries\n with numerator bound and denominator bound, compute det(A).\n\n INPUT:\n\n - ``n`` - matrix dimension (default: ``200``)\n - ``num_bound``...
def vecmat_ZZ(n=300, min=(- 9), max=9, system='sage', times=200): "\n Vector matrix multiplication over ZZ.\n\n Given an n x n matrix A over ZZ with random entries\n between min and max, inclusive, and v the first row of A,\n compute the product v * A.\n\n INPUT:\n\n - ``n`` - matrix dimension ...
def report_GF(p=16411, **kwds): '\n Runs all the reports for finite field matrix operations, for\n prime p=16411.\n\n INPUT:\n\n - ``p`` - ignored\n - ``**kwds`` - passed through to :func:`report`\n\n .. note::\n\n right now, even though p is an input, it is being ignored! If\n yo...
def nullspace_GF(n=300, p=16411, system='sage'): "\n Given a n+1 x n matrix over GF(p) with random\n entries, compute the nullspace.\n\n INPUT:\n\n - ``n`` - matrix dimension (default: 300)\n - ``p`` - prime number (default: ``16411``)\n - ``system`` - either 'magma' or 'sage' (default: 'sage')...
def charpoly_GF(n=100, p=16411, system='sage'): "\n Given a n x n matrix over GF with random entries, compute the\n charpoly.\n\n INPUT:\n\n - ``n`` - matrix dimension (default: 100)\n - ``p`` - prime number (default: ``16411``)\n - ``system`` - either 'magma' or 'sage' (default: 'sage')\n\n ...
def matrix_add_GF(n=1000, p=16411, system='sage', times=100): "\n Given two n x n matrix over GF(p) with random entries, add them.\n\n INPUT:\n\n - ``n`` - matrix dimension (default: 300)\n - ``p`` - prime number (default: ``16411``)\n - ``system`` - either 'magma' or 'sage' (default: 'sage')\n ...
def matrix_multiply_GF(n=100, p=16411, system='sage', times=3): "\n Given an n x n matrix A over GF(p) with random entries, compute\n A * (A+1).\n\n INPUT:\n\n - ``n`` - matrix dimension (default: 100)\n - ``p`` - prime number (default: ``16411``)\n - ``system`` - either 'magma' or 'sage' (defau...
def rank_GF(n=500, p=16411, system='sage'): "\n Rank over GF(p):\n Given a n x (n+10) matrix over GF(p) with random entries, compute the rank.\n\n INPUT:\n\n - ``n`` - matrix dimension (default: 300)\n - ``p`` - prime number (default: ``16411``)\n - ``system`` - either 'magma' or 'sage' (default...
def rank2_GF(n=500, p=16411, system='sage'): "\n Rank over GF(p): Given a (n + 10) x n matrix over GF(p) with\n random entries, compute the rank.\n\n INPUT:\n\n - ``n`` - matrix dimension (default: 300)\n - ``p`` - prime number (default: ``16411``)\n - ``system`` - either 'magma' or 'sage' (defa...
def det_GF(n=400, p=16411, system='sage'): "\n Dense determinant over GF(p).\n Given an n x n matrix A over GF with random entries compute\n det(A).\n\n INPUT:\n\n - ``n`` - matrix dimension (default: 300)\n - ``p`` - prime number (default: ``16411``)\n - ``system`` - either 'magma' or 'sage'...
def hilbert_matrix(n): '\n Returns the Hilbert matrix of size n over rationals.\n\n EXAMPLES::\n\n sage: import sage.matrix.benchmark as b\n sage: b.hilbert_matrix(3)\n [ 1 1/2 1/3]\n [1/2 1/3 1/4]\n [1/3 1/4 1/5]\n ' A = Matrix(QQ, n, n) for i in range(A.nrows...
def echelon_QQ(n=100, min=0, max=9, system='sage'): "\n Given a n x (2*n) matrix over QQ with random integer entries\n between min and max, compute the reduced row echelon form.\n\n INPUT:\n\n - ``n`` - matrix dimension (default: ``300``)\n - ``min`` - minimal value for entries of matrix (default: ...
def inverse_QQ(n=100, min=0, max=9, system='sage'): "\n Given a n x n matrix over QQ with random integer entries\n between min and max, compute the reduced row echelon form.\n\n INPUT:\n\n - ``n`` - matrix dimension (default: ``300``)\n - ``min`` - minimal value for entries of matrix (default: ``-9...
def matrix_multiply_QQ(n=100, bnd=2, system='sage', times=1): "\n Given an n x n matrix A over QQ with random entries\n whose numerators and denominators are bounded by bnd,\n compute A * (A+1).\n\n INPUT:\n\n - ``n`` - matrix dimension (default: ``300``)\n - ``bnd`` - numerator and denominator ...
def det_hilbert_QQ(n=80, system='sage'): "\n Runs the benchmark for calculating the determinant of the hilbert\n matrix over rationals of dimension n.\n\n INPUT:\n\n - ``n`` - matrix dimension (default: ``300``)\n - ``system`` - either 'sage' or 'magma' (default: 'sage')\n\n EXAMPLES::\n\n ...
def invert_hilbert_QQ(n=40, system='sage'): "\n Runs the benchmark for calculating the inverse of the hilbert\n matrix over rationals of dimension n.\n\n INPUT:\n\n - ``n`` - matrix dimension (default: ``300``)\n - ``system`` - either 'sage' or 'magma' (default: 'sage')\n\n EXAMPLES::\n\n ...
def MatrixVector_QQ(n=1000, h=100, system='sage', times=1): "\n Compute product of square ``n`` matrix by random vector with num and\n denom bounded by ``h`` the given number of ``times``.\n\n INPUT:\n\n - ``n`` - matrix dimension (default: ``300``)\n - ``h`` - numerator and denominator bound (defa...
def nullspace_RR(n=300, min=0, max=10, system='sage'): "\n Nullspace over RR:\n Given a n+1 x n matrix over RR with random entries\n between min and max, compute the nullspace.\n\n INPUT:\n\n - ``n`` - matrix dimension (default: ``300``)\n - ``min`` - minimal value for entries of matrix (default...
def nullspace_RDF(n=300, min=0, max=10, system='sage'): "\n Nullspace over RDF:\n Given a n+1 x n matrix over RDF with random entries\n between min and max, compute the nullspace.\n\n INPUT:\n\n - ``n`` - matrix dimension (default: ``300``)\n - ``min`` - minimal value for entries of matrix (def...
def berlekamp_massey(a): '\n Use the Berlekamp-Massey algorithm to find the minimal polynomial\n of a linear recurrence sequence `a`.\n\n The minimal polynomial of a linear recurrence `\\{a_r\\}` is\n by definition the unique monic polynomial `g`, such that if\n `\\{a_r\\}` satisfies a linear recur...
def max_det_prime(n): '\n Return the largest prime so that it is reasonably efficient to\n compute modulo that prime with n x n matrices in LinBox.\n\n INPUT:\n\n - ``n`` -- a positive integer\n\n OUTPUT:\n\n a prime number\n\n EXAMPLES::\n\n sage: from sage.matrix.matrix_integer_dense...
def det_from_modp_and_divisor(A, d, p, z_mod, moduli, z_so_far=ZZ(1), N_so_far=ZZ(1)): '\n This is used for internal purposes for computing determinants\n quickly (with the hybrid p-adic / multimodular algorithm).\n\n INPUT:\n\n - A -- a square matrix\n - d -- a divisor of the determinant of A\n ...
def det_given_divisor(A, d, proof=True, stabilize=2): '\n Given a divisor d of the determinant of A, compute the determinant of A.\n\n INPUT:\n\n - ``A`` -- a square integer matrix\n - ``d`` -- a nonzero integer that is assumed to divide the determinant of A\n - ``proof`` -- bool (default: True) co...
def det_padic(A, proof=True, stabilize=2): "\n Return the determinant of A, computed using a p-adic/multimodular\n algorithm.\n\n INPUT:\n\n - ``A`` -- a square matrix\n\n - ``proof`` -- boolean\n\n - ``stabilize`` (default: 2) -- if proof False, number of successive primes so that\n CRT de...
def double_det(A, b, c, proof): '\n Compute the determinants of the stacked integer matrices\n A.stack(b) and A.stack(c).\n\n INPUT:\n\n - A -- an (n-1) x n matrix\n - b -- a 1 x n matrix\n - c -- a 1 x n matrix\n - proof -- whether or not to compute the det modulo enough times to\n prov...
def add_column_fallback(B, a, proof): "\n Simplistic version of add_column, in case the powerful clever one\n fails (e.g., B is singular).\n\n INPUT:\n\n B -- a square matrix (may be singular)\n a -- an n x 1 matrix, where B has n rows\n proof -- bool; whether to prove result correct...
def solve_system_with_difficult_last_row(B, a): '\n Solve B*x = a when the last row of `B` contains huge entries using\n a clever trick that reduces the problem to solve C*x = a where `C`\n is `B` but with the last row replaced by something small, along\n with one easy null space computation. The lat...
def add_column(B, H_B, a, proof): "\n The add column procedure.\n\n INPUT:\n\n - B -- a square matrix (may be singular)\n - H_B -- the Hermite normal form of B\n - a -- an n x 1 matrix, where B has n rows\n - proof -- bool; whether to prove result correct, in case we use fallback method.\n\n ...
def add_row(A, b, pivots, include_zero_rows): '\n The add row procedure.\n\n INPUT:\n\n - A -- a matrix in Hermite normal form with n column\n - b -- an n x 1 row matrix\n - pivots -- sorted list of integers; the pivot positions of A.\n\n OUTPUT:\n\n - H -- the Hermite normal form of A.stack(...
def pivots_of_hnf_matrix(H): '\n Return the pivot columns of a matrix H assumed to be in HNF.\n\n INPUT:\n\n - H -- a matrix that must be HNF\n\n OUTPUT:\n\n - list -- list of pivots\n\n EXAMPLES::\n\n sage: H = matrix(ZZ, 3, 5, [1, 0, 0, 45, -36, 0, 1, 0, 131, -107, 0, 0, 0, 178, -145]);...
def hnf_square(A, proof): '\n INPUT:\n\n - a nonsingular n x n matrix A over the integers.\n\n OUTPUT:\n\n - the Hermite normal form of A.\n\n EXAMPLES::\n\n sage: import sage.matrix.matrix_integer_dense_hnf as hnf\n sage: A = matrix(ZZ, 3, [-21, -7, 5, 1,20,-7, -1,1,-1])\n sag...
def interleave_matrices(A, B, cols1, cols2): '\n INPUT:\n\n - A, B -- matrices with the same number of rows\n - cols1, cols2 -- disjoint lists of integers\n\n OUTPUT:\n\n construct a new matrix C by sticking the columns\n of A at the positions specified by cols1 and the\n columns of B at the ...
def probable_pivot_rows(A): '\n Return rows of A that are very likely to be pivots.\n\n This really finds the pivots of A modulo a random prime.\n\n INPUT:\n\n - A -- a matrix\n\n OUTPUT:\n\n a tuple of integers\n\n EXAMPLES::\n\n sage: import sage.matrix.matrix_integer_dense_hnf as ma...
def probable_pivot_columns(A): '\n INPUT:\n\n - A -- a matrix\n\n OUTPUT:\n\n a tuple of integers\n\n EXAMPLES::\n\n sage: import sage.matrix.matrix_integer_dense_hnf as matrix_integer_dense_hnf\n sage: a = matrix(ZZ,3,[0, -1, -1, 0, -20, 1, 0, 1, 2])\n sage: a\n [ 0 -...
def ones(H, pivots): '\n Find all 1 pivot columns of the matrix H in Hermite form, along\n with the corresponding rows, and also the non 1 pivot columns and\n non-pivot rows. Here a 1 pivot column is a pivot column so that\n the leading bottom entry is 1.\n\n INPUT:\n\n - H -- matrix in Hermite...
def extract_ones_data(H, pivots): "\n Compute ones data and corresponding submatrices of H.\n\n This is used to optimized the :func:`add_row` function.\n\n INPUT:\n\n - H -- a matrix in HNF\n - pivots -- list of all pivot column positions of H\n\n OUTPUT:\n\n C, D, E, onecol, onerow, non_onec...
def is_in_hnf_form(H, pivots): '\n Return whether the matrix ``H`` is in Hermite normal form\n with given pivot columns.\n\n INPUT:\n\n - ``H`` -- matrix\n - ``pivots`` -- sorted list of integers\n\n OUTPUT:\n\n boolean\n\n EXAMPLES::\n\n sage: a = matrix(ZZ,3,5,[-2, -6, -3, -17, -1...
def probable_hnf(A, include_zero_rows, proof): '\n Return the HNF of A or raise an exception if something involving\n the randomized nature of the algorithm goes wrong along the way.\n\n Calling this function again a few times should result it in it\n working, at least if proof=True.\n\n INPUT:\n\n...
def pad_zeros(A, nrows): '\n Add zeros to the bottom of A so that the resulting matrix has nrows.\n\n INPUT:\n\n - A -- a matrix\n - nrows -- an integer that is at least as big as the number of rows of A.\n\n OUTPUT:\n\n a matrix with nrows rows.\n\n EXAMPLES::\n\n sage: import sage.ma...
def hnf(A, include_zero_rows=True, proof=True): '\n Return the Hermite Normal Form of a general integer matrix A,\n along with the pivot columns.\n\n INPUT:\n\n - A -- an n x m matrix A over the integers.\n - include_zero_rows -- bool (default: True) whether or not to include zero\n rows in th...
def hnf_with_transformation(A, proof=True): '\n Compute the HNF H of A along with a transformation matrix U\n such that U*A = H.\n\n INPUT:\n\n - A -- an n x m matrix A over the integers.\n - proof -- whether or not to prove the result correct.\n\n OUTPUT:\n\n - matrix -- the Hermite normal f...
def hnf_with_transformation_tests(n=10, m=5, trials=10): '\n Use this to randomly test that hnf with transformation matrix\n is working.\n\n EXAMPLES::\n\n sage: from sage.matrix.matrix_integer_dense_hnf import hnf_with_transformation_tests\n sage: hnf_with_transformation_tests(n=15, m=10, ...
def benchmark_hnf(nrange, bits=4): "\n Run benchmark program.\n\n EXAMPLES::\n\n sage: import sage.matrix.matrix_integer_dense_hnf as hnf\n sage: hnf.benchmark_hnf([10,25],32)\n ('sage', 10, 32, ...),\n ('sage', 25, 32, ...),\n " b = (2 ** bits) for n in nrange: ...
def benchmark_magma_hnf(nrange, bits=4): "\n EXAMPLES::\n\n sage: import sage.matrix.matrix_integer_dense_hnf as hnf\n sage: hnf.benchmark_magma_hnf([50,100],32) # optional - magma\n ('magma', 50, 32, ...),\n ('magma', 100, 32, ...),\n " from sage.interfaces.magma import ...
def sanity_checks(times=50, n=8, m=5, proof=True, stabilize=2, check_using_magma=True): "\n Run random sanity checks on the modular p-adic HNF with tall and wide matrices\n both dense and sparse.\n\n INPUT:\n\n - times -- number of times to randomly try matrices with each shape\n - n -- number of r...
def p_saturation(A, p, proof=True): '\n INPUT:\n\n - A -- a matrix over ZZ\n - p -- a prime\n - proof -- bool (default: True)\n\n OUTPUT:\n\n The p-saturation of the matrix A, i.e., a new matrix in Hermite form\n whose row span a ZZ-module that is p-saturated.\n\n EXAMPLES::\n\n sag...
def random_sublist_of_size(k, n): '\n INPUT:\n\n - k -- an integer\n - n -- an integer\n\n OUTPUT:\n\n a randomly chosen sublist of range(k) of size n.\n\n EXAMPLES::\n\n sage: import sage.matrix.matrix_integer_dense_saturation as s\n sage: l = s.random_sublist_of_size(10, 3)\n ...