Vectors with integer entries - Modules

Skip to content
Back to top
View this page
Edit this page

# Vectors with integer entries

AUTHOR:

- William Stein (2007)

EXAMPLES:

Sage

    sage: v = vector(ZZ, [1,2,3,4,5])
    sage: v
    (1, 2, 3, 4, 5)
    sage: 3*v
    (3, 6, 9, 12, 15)
    sage: v*7
    (7, 14, 21, 28, 35)
    sage: -v
    (-1, -2, -3, -4, -5)
    sage: v - v
    (0, 0, 0, 0, 0)
    sage: v + v
    (2, 4, 6, 8, 10)
    sage: v * v   # dot product.
    55

Python

    >>> from sage.all import *
    >>> v = vector(ZZ, [Integer(1),Integer(2),Integer(3),Integer(4),Integer(5)])
    >>> v
    (1, 2, 3, 4, 5)
    >>> Integer(3)*v
    (3, 6, 9, 12, 15)
    >>> v*Integer(7)
    (7, 14, 21, 28, 35)
    >>> -v
    (-1, -2, -3, -4, -5)
    >>> v - v
    (0, 0, 0, 0, 0)
    >>> v + v
    (2, 4, 6, 8, 10)
    >>> v * v   # dot product.
    55

We make a large zero vector:

Sage

    sage: k = ZZ^100000; k
    Ambient free module of rank 100000 over the principal ideal domain Integer Ring
    sage: v = k(0)
    sage: v[:10]
    (0, 0, 0, 0, 0, 0, 0, 0, 0, 0)

[Python]

    >>> from sage.all import *
    >>> k = ZZ**Integer(100000); k
    Ambient free module of rank 100000 over the principal ideal domain Integer Ring
    >>> v = k(Integer(0))
    >>> v[:Integer(10)]
    (0, 0, 0, 0, 0, 0, 0, 0, 0, 0)

class sage.modules.vector_integer_dense.Vector_integer_dense

  Bases: `FreeModuleElement`

  list(copy=True)

    The list of entries of the vector.

    INPUT:

    - `copy` – ignored optional argument

    EXAMPLES:

    Sage

        sage: v = vector([1,2,3,4])
        sage: a = v.list(copy=False); a
        [1, 2, 3, 4]
        sage: a[0] = 0
        sage: v
        (1, 2, 3, 4)

    Python

        >>> from sage.all import *
        >>> v = vector([Integer(1),Integer(2),Integer(3),Integer(4)])
        >>> a = v.list(copy=False); a
        [1, 2, 3, 4]
        >>> a[Integer(0)] = Integer(0)
        >>> v
        (1, 2, 3, 4)

sage.modules.vector_integer_dense.unpickle_v0(parent, entries, degree)

sage.modules.vector_integer_dense.unpickle_v1(parent, entries, degree, immutable)