# HG changeset patch
# User Rob Beezer
# Date 1300750668 25200
# Node ID f93ce2361cc19bcad14c7fbc4309814069633488
# Parent 63144922ed6cda164915a2da7d6629f426de9b60
10977: vector constructor documentation addition
diff r 63144922ed6c r f93ce2361cc1 sage/modules/free_module_element.pyx
 a/sage/modules/free_module_element.pyx Mon Mar 21 14:27:21 2011 0700
+++ b/sage/modules/free_module_element.pyx Mon Mar 21 16:37:48 2011 0700
@@ 157,7 +157,8 @@
INPUT:
 ``object``  a list, dictionary, or other
 iterable containing the entries of the vector
+ iterable containing the entries of the vector, including
+ any object that is palatable to the ``Sequence`` constructor
 ``ring``  a base ring (or field) for the vector
space or free module, which contains all of the elements
@@ 244,7 +245,6 @@
sage: vector(QQ, 4, [1,1/2,1/3,1/4])
(1, 1/2, 1/3, 1/4)

But it is an error if the degree and size of the list of entries
are mismatched::
@@ 346,9 +346,25 @@
(1, 2, 3)
sage: parent(v)
Ambient free module of rank 3 over the principal ideal domain Integer Ring

 Am empty list, without a ring given, will default to the integers. ::

+
+ Complex numbers can be converted naturally to a sequence of length 2. And
+ then to a vector. ::
+
+ sage: c = CDF(2 + 3*I)
+ sage: v = vector(c); v
+ (2.0, 3.0)
+
+ A generator, or other iterable, may also be supplied as input. Anything
+ that can be converted to a :class:`~sage.structure.sequence.Sequence` is
+ a possible input. ::
+
+ sage: type(i^2 for i in range(3))
+
+ sage: v = vector(i^2 for i in range(3)); v
+ (0, 1, 4)
+
+ An empty list, without a ring given, will default to the integers. ::
+
sage: x = vector([]); x
()
sage: x.parent()
@@ 434,7 +450,8 @@
INPUT:
 ``v``  a dictionary with nonnegative integers as keys,
 or a list or other object that can be converted to Sequence
+ or a list or other object that can be converted by the ``Sequence``
+ constructor
 ``R``  a ring containing all the entries, possibly given as ``None``
 ``degree``  a requested size for the list when the input is a dictionary,
otherwise ignored
@@ 486,8 +503,15 @@
...
TypeError: unable to find a common ring for all elements
+ Some objects can be converted to sequences even if they are not always
+ thought of as sequences. ::
+
+ sage: c = CDF(2+3*I)
+ sage: prepare(c, None)
+ ([2.0, 3.0], Real Double Field)
+
This checks a bug listed at Trac #10595. Without good evidence for a ring, the default
 is the integers.
+ is the integers. ::
sage: prepare([], None)
([], Integer Ring)