︠c614f3e0-326c-4d9f-befc-964a5dd758d0s︠ %md Descobrindo os principais métodos de um objeto Sage use a sintexe: **help(obj)**. Veja exemplo a seguir para o objeto V criado como exspaço vetorial sobre $Q$ de dimensão 3. ︡6ac1576d-02b9-4953-8eea-8ed315ae06cc︡{"md":"Descobrindo os principais métodos de um objeto Sage use a sintexe: **help(obj)**. Veja exemplo a seguir para o objeto V criado como exspaço vetorial sobre $Q$ de dimensão 3."}︡{"done":true}︡ ︠b6fb0c22-1c31-40fe-a168-f3fd418a4ef5s︠ V=VectorSpace(QQ,3) help(V) ︡1cb021eb-fcd0-4bba-91ef-3aa52416b0c3︡{"stderr":"\nWARNING: Output: 255904 truncated by MAX_STDOUT_SIZE to 40000. Type 'smc?' to learn how to raise the output limit.","stdout":"Help on FreeModule_ambient_field_with_category in module sage.modules.free_module object:\n\nclass FreeModule_ambient_field_with_category(FreeModule_ambient_field, sage.categories.category.JoinCategory.parent_class)\n | Method resolution order:\n | FreeModule_ambient_field_with_category\n | FreeModule_ambient_field\n | FreeModule_generic_field\n | FreeModule_ambient_pid\n | FreeModule_generic_pid\n | FreeModule_ambient_domain\n | FreeModule_ambient\n | FreeModule_generic\n | sage.modules.module.Module\n | sage.structure.parent.Parent\n | sage.structure.category_object.CategoryObject\n | sage.structure.sage_object.SageObject\n | sage.categories.category.JoinCategory.parent_class\n | sage.categories.finite_dimensional_modules_with_basis.FiniteDimensionalModulesWithBasis.parent_class\n | sage.categories.vector_spaces.VectorSpaces.WithBasis.parent_class\n | sage.categories.modules_with_basis.ModulesWithBasis.parent_class\n | sage.categories.modules.Modules.FiniteDimensional.parent_class\n | sage.categories.vector_spaces.VectorSpaces.parent_class\n | sage.categories.modules.Modules.parent_class\n | sage.categories.bimodules.Bimodules.parent_class\n | sage.categories.right_modules.RightModules.parent_class\n | sage.categories.left_modules.LeftModules.parent_class\n | sage.categories.commutative_additive_groups.CommutativeAdditiveGroups.parent_class\n | sage.categories.additive_groups.AdditiveGroups.parent_class\n | sage.categories.additive_magmas.AdditiveMagmas.AdditiveUnital.AdditiveInverse.parent_class\n | sage.categories.commutative_additive_monoids.CommutativeAdditiveMonoids.parent_class\n | sage.categories.additive_monoids.AdditiveMonoids.parent_class\n | sage.categories.additive_magmas.AdditiveMagmas.AdditiveUnital.parent_class\n | sage.categories.commutative_additive_semigroups.CommutativeAdditiveSemigroups.parent_class\n | sage.categories.additive_magmas.AdditiveMagmas.AdditiveCommutative.parent_class\n | sage.categories.additive_semigroups.AdditiveSemigroups.parent_class\n | sage.categories.additive_magmas.AdditiveMagmas.parent_class\n | sage.categories.sets_cat.Sets.parent_class\n | sage.categories.sets_with_partial_maps.SetsWithPartialMaps.parent_class\n | sage.categories.objects.Objects.parent_class\n | __builtin__.object\n | \n | Methods inherited from FreeModule_ambient_field:\n | \n | __init__(self, base_field, dimension, sparse=False)\n | Create the ambient vector space of given dimension over the given\n | field.\n | \n | INPUT:\n | \n | \n | - ``base_field`` - a field\n | \n | - ``dimension`` - a non-negative integer\n | \n | - ``sparse`` - bool (default: False)\n | \n | \n | EXAMPLES::\n | \n | sage: QQ^3\n | Vector space of dimension 3 over Rational Field\n | \n | ambient_vector_space(self)\n | Returns self as the ambient vector space.\n | \n | EXAMPLES::\n | \n | sage: M = QQ^3\n | sage: M.ambient_vector_space()\n | Vector space of dimension 3 over Rational Field\n | \n | base_field(self)\n | Returns the base field of this vector space.\n | \n | EXAMPLES::\n | \n | sage: M = QQ^3\n | sage: M.base_field()\n | Rational Field\n | \n | ----------------------------------------------------------------------\n | Methods inherited from FreeModule_generic_field:\n | \n | __add__(self, other)\n | Return the sum of self and other.\n | \n | EXAMPLES::\n | \n | sage: V = VectorSpace(QQ,3)\n | sage: V0 = V.span([V.gen(0)])\n | sage: V2 = V.span([V.gen(2)])\n | sage: V0 + V2\n | Vector space of degree 3 and dimension 2 over Rational Field\n | Basis matrix:\n | [1 0 0]\n | [0 0 1]\n | sage: QQ^3 + 0\n | Vector space of dimension 3 over Rational Field\n | \n | __truediv__(self, sub)\n | Return the quotient of self by the given subspace sub.\n | \n | EXAMPLES::\n | \n | sage: V = RDF^3; W = V.span([[1,0,-1], [1,-1,0]])\n | sage: Q = V/W; Q\n | Vector space quotient V/W of dimension 1 over Real Double Field where\n | V: Vector space of dimension 3 over Real Double Field\n | W: Vector space of degree 3 and dimension 2 over Real Double Field\n | Basis matrix:\n | [ 1.0 0.0 -1.0]\n | [ 0.0 1.0 -1.0]\n | sage: type(Q)\n | \n | sage: V([1,2,3])\n | (1.0, 2.0, 3.0)\n | sage: Q == V.quotient(W)\n | True\n | sage: Q(W.0)\n | (0.0)\n | \n | complement(self)\n | Return the complement of ``self`` in the\n | :meth:`~sage.modules.free_module.FreeModule_ambient_field.ambient_vector_space`.\n | \n | EXAMPLES::\n | \n | sage: V = QQ^3\n | sage: V.complement()\n | Vector space of degree 3 and dimension 0 over Rational Field\n | Basis matrix:\n | []\n | sage: V == V.complement().complement()\n | True\n | sage: W = V.span([[1, 0, 1]])\n | sage: X = W.complement(); X\n | Vector space of degree 3 and dimension 2 over Rational Field\n | Basis matrix:\n | [ 1 0 -1]\n | [ 0 1 0]\n | sage: X.complement() == W\n | True\n | sage: X + W == V\n | True\n | \n | Even though we construct a subspace of a subspace, the\n | orthogonal complement is still done in the ambient vector\n | space `\\QQ^3`::\n | \n | sage: V = QQ^3\n | sage: W = V.subspace_with_basis([[1,0,1],[-1,1,0]])\n | sage: X = W.subspace_with_basis([[1,0,1]])\n | sage: X.complement()\n | Vector space of degree 3 and dimension 2 over Rational Field\n | Basis matrix:\n | [ 1 0 -1]\n | [ 0 1 0]\n | \n | All these complements are only done with respect to the inner\n | product in the usual basis. Over finite fields, this means\n | we can get complements which are only isomorphic to a vector\n | space decomposition complement. ::\n | \n | sage: F2 = GF(2,x)\n | sage: V = F2^6\n | sage: W = V.span([[1,1,0,0,0,0]])\n | sage: W\n | Vector space of degree 6 and dimension 1 over Finite Field of size 2\n | Basis matrix:\n | [1 1 0 0 0 0]\n | sage: W.complement()\n | Vector space of degree 6 and dimension 5 over Finite Field of size 2\n | Basis matrix:\n | [1 1 0 0 0 0]\n | [0 0 1 0 0 0]\n | [0 0 0 1 0 0]\n | [0 0 0 0 1 0]\n | [0 0 0 0 0 1]\n | sage: W.intersection(W.complement())\n | Vector space of degree 6 and dimension 1 over Finite Field of size 2\n | Basis matrix:\n | [1 1 0 0 0 0]\n | \n | echelonized_basis_matrix(self)\n | Return basis matrix for self in row echelon form.\n | \n | EXAMPLES::\n | \n | sage: V = FreeModule(QQ, 3).span_of_basis([[1,2,3],[4,5,6]])\n | sage: V.basis_matrix()\n | [1 2 3]\n | [4 5 6]\n | sage: V.echelonized_basis_matrix()\n | [ 1 0 -1]\n | [ 0 1 2]\n | \n | intersection(self, other)\n | Return the intersection of self and other, which must be\n | R-submodules of a common ambient vector space.\n | \n | EXAMPLES::\n | \n | sage: V = VectorSpace(QQ,3)\n | sage: W1 = V.submodule([V.gen(0), V.gen(0) + V.gen(1)])\n | sage: W2 = V.submodule([V.gen(1), V.gen(2)])\n | sage: W1.intersection(W2)\n | Vector space of degree 3 and dimension 1 over Rational Field\n | Basis matrix:\n | [0 1 0]\n | sage: W2.intersection(W1)\n | Vector space of degree 3 and dimension 1 over Rational Field\n | Basis matrix:\n | [0 1 0]\n | sage: V.intersection(W1)\n | Vector space of degree 3 and dimension 2 over Rational Field\n | Basis matrix:\n | [1 0 0]\n | [0 1 0]\n | sage: W1.intersection(V)\n | Vector space of degree 3 and dimension 2 over Rational Field\n | Basis matrix:\n | [1 0 0]\n | [0 1 0]\n | sage: Z = V.submodule([])\n | sage: W1.intersection(Z)\n | Vector space of degree 3 and dimension 0 over Rational Field\n | Basis matrix:\n | []\n | \n | is_subspace(self, other)\n | True if this vector space is a subspace of other.\n | \n | EXAMPLES::\n | \n | sage: V = VectorSpace(QQ,3)\n | sage: W = V.subspace([V.gen(0), V.gen(0) + V.gen(1)])\n | sage: W2 = V.subspace([V.gen(1)])\n | sage: W.is_subspace(V)\n | True\n | sage: W2.is_subspace(V)\n | True\n | sage: W.is_subspace(W2)\n | False\n | sage: W2.is_subspace(W)\n | True\n | \n | linear_dependence(self, vectors, zeros='left', check=True)\n | Returns a list of vectors giving relations of linear dependence for the input list of vectors.\n | Can be used to check linear independence of a set of vectors.\n | \n | INPUT:\n | \n | - ``vectors`` -- A list of vectors, all from the same vector\n | space.\n | \n | - ``zeros`` -- default: ``'left'`` - ``'left'`` or ``'right'``\n | as a general preference for where zeros are located in the\n | returned coefficients\n | \n | - ``check`` -- default: ``True`` - if ``True`` each item in\n | the list ``vectors`` is checked for membership in ``self``.\n | Set to ``False`` if you can be certain the vectors come from\n | the vector space.\n | \n | OUTPUT:\n | \n | Returns a list of vectors. The scalar entries of each vector provide\n | the coefficients for a linear combination of the input vectors that\n | will equal the zero vector in ``self``. Furthermore, the returned list\n | is linearly independent in the vector space over the same base field\n | with degree equal to the length of the list ``vectors``.\n | \n | The linear independence of ``vectors`` is equivalent to the returned\n | list being empty, so this provides a test - see the examples below.\n | \n | The returned vectors are always independent, and with ``zeros`` set to\n | ``'left'`` they have 1's in their first non-zero entries and a qualitative\n | disposition to having zeros in the low-index entries. With ``zeros`` set\n | to ``'right'`` the situation is reversed with a qualitative disposition\n | for zeros in the high-index entries.\n | \n | If the vectors in ``vectors`` are made the rows of a matrix `V` and\n | the returned vectors are made the rows of a matrix `R`, then the\n | matrix product `RV` is a zero matrix of the proper size. And\n | `R` is a matrix of full rank. This routine uses kernels of\n | matrices to compute these relations of linear dependence,\n | but handles all the conversions between sets of vectors\n | and matrices. If speed is important, consider working with\n | the appropriate matrices and kernels instead.\n | \n | EXAMPLES:\n | \n | We begin with two linearly independent vectors, and add three\n | non-trivial linear combinations to the set. We illustrate\n | both types of output and check a selected relation of linear\n | dependence. ::\n | \n | sage: v1 = vector(QQ, [2, 1, -4, 3])\n | sage: v2 = vector(QQ, [1, 5, 2, -2])\n | sage: V = QQ^4\n | sage: V.linear_dependence([v1,v2])\n | [\n | \n | ]\n | \n | sage: v3 = v1 + v2\n | sage: v4 = 3*v1 - 4*v2\n | sage: v5 = -v1 + 2*v2\n | sage: L = [v1, v2, v3, v4, v5]\n | \n | sage: relations = V.linear_dependence(L, zeros='left')\n | sage: relations\n | [\n | (1, 0, 0, -1, -2),\n | (0, 1, 0, -1/2, -3/2),\n | (0, 0, 1, -3/2, -7/2)\n | ]\n | sage: v2 + (-1/2)*v4 + (-3/2)*v5\n | (0, 0, 0, 0)\n | \n | sage: relations = V.linear_dependence(L, zeros='right')\n | sage: relations\n | [\n | (-1, -1, 1, 0, 0),\n | (-3, 4, 0, 1, 0),\n | (1, -2, 0, 0, 1)\n | ]\n | sage: z = sum([relations[2][i]*L[i] for i in range(len(L))])\n | sage: z == zero_vector(QQ, 4)\n | True\n | \n | A linearly independent set returns an empty list,\n | a result that can be tested. ::\n | \n | sage: v1 = vector(QQ, [0,1,-3])\n | sage: v2 = vector(QQ, [4,1,0])\n | sage: V = QQ^3\n | sage: relations = V.linear_dependence([v1, v2]); relations\n | [\n | \n | ]\n | sage: relations == []\n | True\n | \n | Exact results result from exact fields. We start with three\n | linearly independent vectors and add in two linear combinations\n | to make a linearly dependent set of five vectors. ::\n | \n | sage: F = FiniteField(17)\n | sage: v1 = vector(F, [1, 2, 3, 4, 5])\n | sage: v2 = vector(F, [2, 4, 8, 16, 15])\n | sage: v3 = vector(F, [1, 0, 0, 0, 1])\n | sage: (F^5).linear_dependence([v1, v2, v3]) == []\n | True\n | sage: L = [v1, v2, v3, 2*v1+v2, 3*v2+6*v3]\n | sage: (F^5).linear_dependence(L)\n | [\n | (1, 0, 16, 8, 3),\n | (0, 1, 2, 0, 11)\n | ]\n | sage: v1 + 16*v3 + 8*(2*v1+v2) + 3*(3*v2+6*v3)\n | (0, 0, 0, 0, 0)\n | sage: v2 + 2*v3 + 11*(3*v2+6*v3)\n | (0, 0, 0, 0, 0)\n | sage: (F^5).linear_dependence(L, zeros='right')\n | [\n | (15, 16, 0, 1, 0),\n | (0, 14, 11, 0, 1)\n | ]\n | \n | TESTS:\n | \n | With ``check=True`` (the default) a mismatch between vectors\n | and the vector space is caught. ::\n | \n | sage: v1 = vector(RR, [1,2,3])\n | sage: v2 = vector(RR, [1,2,3,4])\n | sage: (RR^3).linear_dependence([v1,v2], check=True)\n | Traceback (most recent call last):\n | ...\n | ValueError: vector (1.00000000000000, 2.00000000000000, 3.00000000000000, 4.00000000000000) is not an element of Vector space of dimension 3 over Real Field with 53 bits of precision\n | \n | The ``zeros`` keyword is checked. ::\n | \n | sage: (QQ^3).linear_dependence([vector(QQ,[1,2,3])], zeros='bogus')\n | Traceback (most recent call last):\n | ...\n | ValueError: 'zeros' keyword must be 'left' or 'right', not 'bogus'\n | \n | An empty input set is linearly independent, vacuously. ::\n | \n | sage: (QQ^3).linear_dependence([]) == []\n | True\n | \n | quotient(self, sub, check=True)\n | Return the quotient of self by the given subspace sub.\n | \n | INPUT:\n | \n | \n | - ``sub`` - a submodule of self, or something that can\n | be turned into one via self.submodule(sub).\n | \n | - ``check`` - (default: True) whether or not to check\n | that sub is a submodule.\n | \n | \n | EXAMPLES::\n | \n | sage: A = QQ^3; V = A.span([[1,2,3], [4,5,6]])\n | sage: Q = V.quotient( [V.0 + V.1] ); Q\n | Vector space quotient V/W of dimension 1 over Rational Field where\n | V: Vector space of degree 3 and dimension 2 over Rational Field\n | Basis matrix:\n | [ 1 0 -1]\n | [ 0 1 2]\n | W: Vector space of degree 3 and dimension 1 over Rational Field\n | Basis matrix:\n | [1 1 1]\n | sage: Q(V.0 + V.1)\n | (0)\n | \n | We illustrate the the base rings must be the same::\n | \n | sage: (QQ^2)/(ZZ^2)\n | Traceback (most recent call last):\n | ...\n | ValueError: base rings must be the same\n | \n | quotient_abstract(self, sub, check=True)\n | Returns an ambient free module isomorphic to the quotient space of\n | self modulo sub, together with maps from self to the quotient, and\n | a lifting map in the other direction.\n | \n | Use ``self.quotient(sub)`` to obtain the quotient\n | module as an object equipped with natural maps in both directions,\n | and a canonical coercion.\n | \n | INPUT:\n | \n | \n | - ``sub`` - a submodule of self, or something that can\n | be turned into one via self.submodule(sub).\n | \n | - ``check`` - (default: True) whether or not to check\n | that sub is a submodule.\n | \n | \n | OUTPUT:\n | \n | \n | - ``U`` - the quotient as an abstract *ambient* free\n | module\n | \n | - ``pi`` - projection map to the quotient\n | \n | - ``lift`` - lifting map back from quotient\n | \n | \n | EXAMPLES::\n | \n | sage: V = GF(19)^3\n | sage: W = V.span_of_basis([ [1,2,3], [1,0,1] ])\n | sage: U,pi,lift = V.quotient_abstract(W)\n | sage: pi(V.2)\n | (18)\n | sage: pi(V.0)\n | (1)\n | sage: pi(V.0 + V.2)\n | (0)\n | \n | Another example involving a quotient of one subspace by another.\n | \n | ::\n | \n | sage: A = matrix(QQ,4,4,[0,1,0,0, 0,0,1,0, 0,0,0,1, 0,0,0,0])\n | sage: V = (A^3).kernel()\n | sage: W = A.kernel()\n | sage: U, pi, lift = V.quotient_abstract(W)\n | sage: [pi(v) == 0 for v in W.gens()]\n | [True]\n | sage: [pi(lift(b)) == b for b in U.basis()]\n | [True, True]\n | \n | scale(self, other)\n | Return the product of self by the number other, which is the module\n | spanned by other times each basis vector. Since self is a vector\n | space this product equals self if other is nonzero, and is the zero\n | vector space if other is 0.\n | \n | EXAMPLES::\n | \n | sage: V = QQ^4\n | sage: V.scale(5)\n | Vector space of dimension 4 over Rational Field\n | sage: V.scale(0)\n | Vector space of degree 4 and dimension 0 over Rational Field\n | Basis matrix:\n | []\n | \n | ::\n | \n | sage: W = V.span([[1,1,1,1]])\n | sage: W.scale(2)\n | Vector space of degree 4 and dimension 1 over Rational Field\n | Basis matrix:\n | [1 1 1 1]\n | sage: W.scale(0)\n | Vector space of degree 4 and dimension 0 over Rational Field\n | Basis matrix:\n | []\n | \n | ::\n | \n | sage: V = QQ^4; V\n | Vector space of dimension 4 over Rational Field\n | sage: V.scale(3)\n | Vector space of dimension 4 over Rational Field\n | sage: V.scale(0)\n | Vector space of degree 4 and dimension 0 over Rational Field\n | Basis matrix:\n | []\n | \n | span(self, gens, base_ring=None, check=True, already_echelonized=False)\n | Return the K-span of the given list of gens, where K is the\n | base field of self or the user-specified base_ring. Note that\n | this span is a subspace of the ambient vector space, but need\n | not be a subspace of self.\n | \n | INPUT:\n | \n | \n | - ``gens`` - list of vectors\n | \n | - ``check`` - bool (default: True): whether or not to\n | coerce entries of gens into base field\n | \n | - ``already_echelonized`` - bool (default: False):\n | set this if you know the gens are already in echelon form\n | \n | \n | EXAMPLES::\n | \n | sage: V = VectorSpace(GF(7), 3)\n | sage: W = V.subspace([[2,3,4]]); W\n | Vector space of degree 3 and dimension 1 over Finite Field of size 7\n | Basis matrix:\n | [1 5 2]\n | sage: W.span([[1,1,1]])\n | Vector space of degree 3 and dimension 1 over Finite Field of size 7\n | Basis matrix:\n | [1 1 1]\n | \n | TESTS::\n | \n | sage: V = FreeModule(RDF,3)\n | sage: W = V.submodule([V.gen(0)])\n | sage: W.span([V.gen(1)], base_ring=GF(7))\n | Vector space of degree 3 and dimension 1 over Finite Field of size 7\n | Basis matrix:\n | [0 1 0]\n | sage: v = V((1, pi, log(2))); v\n | (1.0, 3.141592653589793, 0.6931471805599453)\n | sage: W.span([v], base_ring=GF(7))\n | Traceback (most recent call last):\n | ...\n | ValueError: Argument gens (= [(1.0, 3.141592653589793, 0.6931471805599453)]) is not compatible with base_ring (= Finite Field of size 7).\n | sage: W = V.submodule([v])\n | sage: W.span([V.gen(2)], base_ring=GF(7))\n | Vector space of degree 3 and dimension 1 over Finite Field of size 7\n | Basis matrix:\n | [0 0 1]\n | \n | span_of_basis(self, basis, base_ring=None, check=True, already_echelonized=False)\n | Return the free K-module with the given basis, where K is the base\n | field of self or user specified base_ring.\n | \n | Note that this span is a subspace of the ambient vector space, but\n | need not be a subspace of self.\n | \n | INPUT:\n | \n | \n | - ``basis`` - list of vectors\n | \n | - ``check`` - bool (default: True): whether or not to\n | coerce entries of gens into base field\n | \n | - ``already_echelonized`` - bool (default: False):\n | set this if you know the gens are already in echelon form\n | \n | \n | EXAMPLES::\n | \n | sage: V = VectorSpace(GF(7), 3)\n | sage: W = V.subspace([[2,3,4]]); W\n | Vector space of degree 3 and dimension 1 over Finite Field of size 7\n | Basis matrix:\n | [1 5 2]\n | sage: W.span_of_basis([[2,2,2], [3,3,0]])\n | Vector space of degree 3 and dimension 2 over Finite Field of size 7\n | User basis matrix:\n | [2 2 2]\n | [3 3 0]\n | \n | The basis vectors must be linearly independent or a\n | ``ValueError`` exception is raised::\n | \n | sage: W.span_of_basis([[2,2,2], [3,3,3]])\n | Traceback (most recent call last):\n | ...\n | ValueError: The given basis vectors must be linearly independent.\n | \n | subspace(self, gens, check=True, already_echelonized=False)\n | Return the subspace of self spanned by the elements of gens.\n | \n | INPUT:\n | \n | - ``gens`` - list of vectors\n | \n | - ``check`` - bool (default: True) verify that gens\n | are all in self.\n | \n | - ``already_echelonized`` - bool (default: False) set\n | to True if you know the gens are in Echelon form.\n | \n | EXAMPLES:\n | \n | First we create a 1-dimensional vector subspace of an\n | ambient `3`-dimensional space over the finite field of\n | order `7`::\n | \n | sage: V = VectorSpace(GF(7), 3)\n | sage: W = V.subspace([[2,3,4]]); W\n | Vector space of degree 3 and dimension 1 over Finite Field of size 7\n | Basis matrix:\n | [1 5 2]\n | \n | Next we create an invalid subspace, but it's allowed since\n | ``check=False``. This is just equivalent to computing\n | the span of the element::\n | \n | sage: W.subspace([[1,1,0]], check=False)\n | Vector space of degree 3 and dimension 1 over Finite Field of size 7\n | Basis matrix:\n | [1 1 0]\n | \n | With ``check=True`` (the default) the mistake is correctly\n | detected and reported with an ``ArithmeticError`` exception::\n | \n | sage: W.subspace([[1,1,0]], check=True)\n | Traceback (most recent call last):\n | ...\n | ArithmeticError: Argument gens (= [[1, 1, 0]]) does not generate a submodule of self.\n | \n | subspace_with_basis(self, gens, check=True, already_echelonized=False)\n | Same as ``self.submodule_with_basis(...)``.\n | \n | EXAMPLES:\n | \n | We create a subspace with a user-defined basis.\n | \n | ::\n | \n | sage: V = VectorSpace(GF(7), 3)\n | sage: W = V.subspace_with_basis([[2,2,2], [1,2,3]]); W\n | Vector space of degree 3 and dimension 2 over Finite Field of size 7\n | User basis matrix:\n | [2 2 2]\n | [1 2 3]\n | \n | We then create a subspace of the subspace with user-defined basis.\n | \n | ::\n | \n | sage: W1 = W.subspace_with_basis([[3,4,5]]); W1\n | Vector space of degree 3 and dimension 1 over Finite Field of size 7\n | User basis matrix:\n | [3 4 5]\n | \n | Notice how the basis for the same subspace is different if we\n | merely use the ``subspace`` command.\n | \n | ::\n | \n | sage: W2 = W.subspace([[3,4,5]]); W2\n | Vector space of degree 3 and dimension 1 over Finite Field of size 7\n | Basis matrix:\n | [1 6 4]\n | \n | Nonetheless the two subspaces are equal (as mathematical objects)::\n | \n | sage: W1 == W2\n | True\n | \n | subspaces(self, dim)\n | Iterate over all subspaces of dimension dim.\n | \n | INPUT:\n | \n | - ``dim`` - int, dimension of subspaces to be generated\n | \n | EXAMPLE::\n | \n | sage: V = VectorSpace(GF(3), 5)\n | sage: len(list(V.subspaces(0)))\n | 1\n | sage: len(list(V.subspaces(1)))\n | 121\n | sage: len(list(V.subspaces(2)))\n | 1210\n | sage: len(list(V.subspaces(3)))\n | 1210\n | sage: len(list(V.subspaces(4)))\n | 121\n | sage: len(list(V.subspaces(5)))\n | 1\n | \n | ::\n | \n | sage: V = VectorSpace(GF(3), 5)\n | sage: V = V.subspace([V([1,1,0,0,0]),V([0,0,1,1,0])])\n | sage: list(V.subspaces(1))\n | [Vector space of degree 5 and dimension 1 over Finite Field of size 3\n | Basis matrix:\n | [1 1 0 0 0],\n | Vector space of degree 5 and dimension 1 over Finite Field of size 3\n | Basis matrix:\n | [1 1 1 1 0],\n | Vector space of degree 5 and dimension 1 over Finite Field of size 3\n | Basis matrix:\n | [1 1 2 2 0],\n | Vector space of degree 5 and dimension 1 over Finite Field of size 3\n | Basis matrix:\n | [0 0 1 1 0]]\n | \n | vector_space(self, base_field=None)\n | Return the vector space associated to self. Since self is a vector\n | space this function simply returns self, unless the base field is\n | different.\n | \n | EXAMPLES::\n | \n | sage: V = span([[1,2,3]],QQ); V\n | Vector space of degree 3 and dimension 1 over Rational Field\n | Basis matrix:\n | [1 2 3]\n | sage: V.vector_space()\n | Vector space of degree 3 and dimension 1 over Rational Field\n | Basis matrix:\n | [1 2 3]\n | \n | zero_submodule(self)\n | Return the zero submodule of self.\n | \n | EXAMPLES::\n | \n | sage: (QQ^4).zero_submodule()\n | Vector space of degree 4 and dimension 0 over Rational Field\n | Basis matrix:\n | []\n | \n | zero_subspace(self)\n | Return the zero subspace of self.\n | \n | EXAMPLES::\n | \n | sage: (QQ^4).zero_subspace()\n | Vector space of degree 4 and dimension 0 over Rational Field\n | Basis matrix:\n | []\n | \n | ----------------------------------------------------------------------\n | Methods inherited from FreeModule_generic_pid:\n | \n | __radd__(self, other)\n | EXAMPLES::\n | \n | sage: int(0) + QQ^3\n | Vector space of dimension 3 over Rational Field\n | sage: sum([QQ^3, QQ^3])\n | Vector space of degree 3 and dimension 3 over Rational Field\n | Basis matrix:\n | [1 0 0]\n | [0 1 0]\n | [0 0 1]\n | \n | denominator(self)\n | The denominator of the basis matrix of self (i.e. the LCM of the\n | coordinate entries with respect to the basis of the ambient\n | space).\n | \n | EXAMPLES::\n | \n | sage: V = QQ^3\n | sage: L = V.span([[1,1/2,1/3], [-1/5,2/3,3]],ZZ)\n | sage: L\n | Free module of degree 3 and rank 2 over Integer Ring\n | Echelon basis matrix:\n | [ 1/5 19/6 37/3]\n | [ 0 23/6 46/3]\n | sage: L.denominator()\n | 30\n | \n | index_in(self, other)\n | Return the lattice index [other:self] of self in other, as an\n | element of the base field. When self is contained in other, the\n | lattice index is the usual index. If the index is infinite, then\n | this function returns infinity.\n | \n | EXAMPLES::\n | \n | sage: L1 = span([[1,2]], ZZ)\n | sage: L2 = span([[3,6]], ZZ)\n | sage: L2.index_in(L1)\n | 3\n | \n | Note that the free modules being compared need not be integral.\n | \n | ::\n | \n | sage: L1 = span([['1/2','1/3'], [4,5]], ZZ)\n | sage: L2 = span([[1,2], [3,4]], ZZ)\n | sage: L2.index_in(L1)\n | 12/7\n | sage: L1.index_in(L2)\n | 7/12\n | sage: L1.discriminant() / L2.discriminant()\n | 49/144\n | \n | The index of a lattice of infinite index is infinite.\n | \n | ::\n | \n | sage: L1 = FreeModule(ZZ, 2)\n | sage: L2 = span([[1,2]], ZZ)\n | sage: L2.index_in(L1)\n | +Infinity\n | \n | index_in_saturation(self)\n | Return the index of this module in its saturation, i.e., its\n | intersection with `R^n`.\n | \n | EXAMPLES::\n | \n | sage: W = span([[2,4,6]], ZZ)\n | sage: W.index_in_saturation()\n | 2\n | sage: W = span([[1/2,1/3]], ZZ)\n | sage: W.index_in_saturation()\n | 1/6\n | \n | saturation(self)\n | Return the saturated submodule of `R^n` that spans the same\n | vector space as self.\n | \n | EXAMPLES:\n | \n | We create a 1-dimensional lattice that is obviously not\n | saturated and saturate it.\n | \n | ::\n | \n | sage: L = span([[9,9,6]], ZZ); L\n | Free module of degree 3 and rank 1 over Integer Ring\n | Echelon basis matrix:\n | [9 9 6]\n | sage: L.saturation()\n | Free module of degree 3 and rank 1 over Integer Ring\n | Echelon basis matrix:\n | [3 3 2]\n | \n | We create a lattice spanned by two vectors, and saturate.\n | Computation of discriminants shows that the index of lattice in its\n | saturation is `3`, which is a prime of congruence between\n | the two generating vectors.\n | \n | ::\n | \n | sage: L = span([[1,2,3], [4,5,6]], ZZ)\n | sage: L.saturation()\n | Free module of degree 3 and rank 2 over Integer Ring\n | Echelon basis matrix:\n | [ 1 0 -1]\n | [ 0 1 2]\n | sage: L.discriminant()\n | 54\n | sage: L.saturation().discriminant()\n | 6\n | \n | Notice that the saturation of a non-integral lattice `L` is\n | defined, but the result is integral hence does not contain\n | `L`::\n | \n | sage: L = span([['1/2',1,3]], ZZ)\n | sage: L.saturation()\n | Free module of degree 3 and rank 1 over Integer Ring\n | Echelon basis matrix:\n | [1 2 6]\n | \n | submodule(self, gens, check=True, already_echelonized=False)\n | Create the R-submodule of the ambient vector space with given\n | generators, where R is the base ring of self.\n | \n | INPUT:\n | \n | \n | - ``gens`` - a list of free module elements or a free\n | module\n | \n | - ``check`` - (default: True) whether or not to verify\n | that the gens are in self.\n | \n | \n | OUTPUT:\n | \n | \n | - ``FreeModule`` - the submodule spanned by the\n | vectors in the list gens. The basis for the subspace is always put\n | in reduced row echelon form.\n | \n | \n | EXAMPLES:\n | \n | We create a submodule of `\\ZZ^3`::\n | \n | sage: M = FreeModule(ZZ, 3)\n | sage: B = M.basis()\n | sage: W = M.submodule([B[0]+B[1], 2*B[1]-B[2]])\n | sage: W\n | Free module of degree 3 and rank 2 over Integer Ring\n | Echelon basis matrix:\n | [ 1 1 0]\n | [ 0 2 -1]\n | \n | We create a submodule of a submodule.\n | \n | ::\n | \n | sage: W.submodule([3*B[0] + 3*B[1]])\n | Free module of degree 3 and rank 1 over Integer Ring\n | Echelon basis matrix:\n | [3 3 0]\n | \n | We try to create a submodule that isn't really a submodule,\n | which results in an ``ArithmeticError`` exception::\n | \n | sage: W.submodule([B[0] - B[1]])\n | Traceback (most recent call last):\n | ...\n | ArithmeticError: Argument gens (= [(1, -1, 0)]) does not generate a submodule of self.\n | \n | Next we create a submodule of a free module over the principal ideal\n | domain `\\QQ[x]`, which uses the general Hermite normal form functionality::\n | \n | sage: R = PolynomialRing(QQ, 'x'); x = R.gen()\n | sage: M = FreeModule(R, 3)\n | sage: B = M.basis()\n | sage: W = M.submodule([x*B[0], 2*B[1]- x*B[2]]); W\n | Free module of degree 3 and rank 2 over Univariate Polynomial Ring in x over Rational Field\n | Echelon basis matrix:\n | [ x 0 0]\n | [ 0 2 -x]\n | sage: W.ambient_module()\n | Ambient free module of rank 3 over the principal ideal domain Univariate Polynomial Ring in x over Rational Field\n | \n | submodule_with_basis(self, basis, check=True, already_echelonized=False)\n | Create the R-submodule of the ambient vector space with given\n | basis, where R is the base ring of self.\n | \n | INPUT:\n | \n | - ``basis`` -- a list of linearly independent vectors\n | \n | - ``check`` -- whether or not to verify that each gen is in\n | the ambient vector space\n | \n | OUTPUT:\n | \n | - ``FreeModule`` -- the `R`-submodule with given basis\n | \n | EXAMPLES:\n | \n | First we create a submodule of `\\ZZ^3`::\n | \n | sage: M = FreeModule(ZZ, 3)\n | sage: B = M.basis()\n | sage: N = M.submodule_with_basis([B[0]+B[1], 2*B[1]-B[2]])\n | sage: N\n | Free module of degree 3 and rank 2 over Integer Ring\n | User basis matrix:\n | [ 1 1 0]\n | [ 0 2 -1]\n | \n | A list of vectors in the ambient vector space may fail to generate\n | a submodule.\n | \n | ::\n | \n | sage: V = M.ambient_vector_space()\n | sage: X = M.submodule_with_basis([ V(B[0]+B[1])/2, V(B[1]-B[2])/2])\n | Traceback (most recent call last):\n | ...\n | ArithmeticError: The given basis does not generate a submodule of self.\n | \n | However, we can still determine the R-span of vectors in the\n | ambient space, or over-ride the submodule check by setting check to\n | False.\n | \n | ::\n | \n | sage: X = V.span([ V(B[0]+B[1])/2, V(B[1]-B[2])/2 ], ZZ)\n | sage: X\n | Free module of degree 3 and rank 2 over Integer Ring\n | Echelon basis matrix:\n | [ 1/2 0 1/2]\n | [ 0 1/2 -1/2]\n | sage: Y = M.submodule([ V(B[0]+B[1])/2, V(B[1]-B[2])/2 ], check=False)\n | sage: X == Y\n | True\n | \n | Next we try to create a submodule of a free module over the\n | principal ideal domain `\\QQ[x]`, using our general Hermite normal form implementation::\n | \n | sage: R = PolynomialRing(QQ, 'x'); x = R.gen()\n | sage: M = FreeModule(R, 3)\n | sage: B = M.basis()\n | sage: W = M.submodule_with_basis([x*B[0], 2*B[0]- x*B[2]]); W\n | Free module of degree 3 and rank 2 over Univariate Polynomial Ring in x over Rational Field\n | User basis matrix:\n | [ x 0 0]\n | [ 2 0 -x]\n | \n | vector_space_span(self, gens, check=True)\n | Create the vector subspace of the ambient vector space with given\n | generators.\n | \n | INPUT:\n | \n | \n | - ``gens`` - a list of vector in self\n | \n | - ``check`` - whether or not to verify that each gen\n | is in the ambient vector space\n | \n | \n | OUTPUT: a vector subspace\n | \n | EXAMPLES:\n | \n | We create a `2`-dimensional subspace of `\\QQ^3`.\n | \n | ::\n | \n | sage: V = VectorSpace(QQ, 3)\n | sage: B = V.basis()\n | sage: W = V.vector_space_span([B[0]+B[1], 2*B[1]-B[2]])\n | sage: W\n | Vector space of degree 3 and dimension 2 over Rational Field\n | Basis matrix:\n | [ 1 0 1/2]\n | [ 0 1 -1/2]\n | \n | We create a subspace of a vector space over\n | `\\QQ(i)`.\n | \n | ::\n | \n | sage: R. = QQ[]\n | sage: K = NumberField(x^2 + 1, 'a'); a = K.gen()\n | sage: V = VectorSpace(K, 3)\n | sage: V.vector_space_span([2*V.gen(0) + 3*V.gen(2)])\n | Vector space of degree 3 and dimension 1 over Number Field in a with defining polynomial x^2 + 1\n | Basis matrix:\n | [ 1 0 3/2]\n | \n | We use the ``vector_space_span`` command to create a\n | vector subspace of the ambient vector space of a submodule of\n | `\\ZZ^3`.\n | \n | ::\n | \n | sage: M = FreeModule(ZZ,3)\n | sage: W = M.submodule([M([1,2,3])])\n | sage: W.vector_space_span([M([2,3,4])])\n | Vector space of degree 3 and dimension 1 over Rational Field\n | Basis matrix:\n | [ 1 3/2 2]\n | \n | vector_space_span_of_basis(self, basis, check=True)\n | Create the vector subspace of the ambient vector space with given\n | basis.\n | \n | INPUT:\n | \n | - ``basis`` -- a list of linearly independent vectors\n | \n | - ``check`` -- whether or not to verify that each gen is in\n | the ambient vector space\n | \n | OUTPUT: a vector subspace with user-specified basis\n | \n | EXAMPLES::\n | \n | sage: V = VectorSpace(QQ, 3)\n | sage: B = V.basis()\n | sage: W = V.vector_space_span_of_basis([B[0]+B[1], 2*B[1]-B[2]])\n | sage: W\n | Vector space of degree 3 and dimension 2 over Rational Field\n | User basis matrix:\n | [ 1 1 0]\n | [ 0 2 -1]\n | \n | ----------------------------------------------------------------------\n | Methods inherited from FreeModule_ambient_domain:\n | \n | coordinate_vector(self, v, check=True)\n | Write `v` in terms of the standard basis for self and\n | return the resulting coefficients in a vector over the fraction\n | field of the base ring.\n | \n | INPUT:\n | \n | - ``v`` -- vector\n | \n | - ``check`` -- bool (default: True); if True, also verify that\n | `v` is really in self.\n | \n | [...]"}︡{"stdout":"\n"}︡{"done":true}︡ ︠1763553f-d1fb-4f1e-8845-c0c09955060d︠ ︡c9a5189a-5f8e-4f9d-959a-a2b77d89619e︡