439 | | """ |
440 | | Return the `R`-span of gens (a list of vectors) where R = |
441 | | base_ring. |
442 | | |
443 | | EXAMPLES:: |
444 | | |
| 439 | r""" |
| 440 | Return the span of the vectors in ``gens`` using scalars from ``base_ring``. |
| 441 | |
| 442 | INPUTS: |
| 443 | |
| 444 | - ``gens`` - a list of either vectors or lists of ring elements |
| 445 | used to generate the span |
| 446 | |
| 447 | - ``base_ring`` - default: ``None`` - a principal ideal domain |
| 448 | for the ring of scalars |
| 449 | |
| 450 | - ``check`` - default: ``True`` - passed to the ``span()`` method |
| 451 | of the ambient module |
| 452 | |
| 453 | - ``already_echelonized`` - default: ``False`` - set to ``True`` |
| 454 | if the vectors form the rows of a matrix in echelon form, in |
| 455 | order to skip the computation of an echelonized basis for the |
| 456 | span. |
| 457 | |
| 458 | EXAMPLES: |
| 459 | |
| 460 | The vectors in the list of generators can be given as |
| 461 | lists, provided a base ring is specified and the elements of the list |
| 462 | are in the ring (or the fraction field of the ring). If the |
| 463 | base ring is a field, the span is a vector space. :: |
| 464 | |
458 | | |
| 480 | |
| 481 | If the base ring is not a field, then a module is created. |
| 482 | The entries of the vectors can lie outside the ring, if they |
| 483 | are in the fraction field of the ring. :: |
| 484 | |
| 485 | sage: span([[1,2,5], [2,2,2]], ZZ) |
| 486 | Free module of degree 3 and rank 2 over Integer Ring |
| 487 | Echelon basis matrix: |
| 488 | [ 1 0 -3] |
| 489 | [ 0 2 8] |
| 490 | |
| 491 | sage: span([[1,1,1], [1,1/2,1]], ZZ) |
| 492 | Free module of degree 3 and rank 2 over Integer Ring |
| 493 | Echelon basis matrix: |
| 494 | [ 1 0 1] |
| 495 | [ 0 1/2 0] |
| 496 | |
| 497 | sage: R.<x> = QQ[] |
| 498 | sage: M= span( [[x, x^2+1], [1/x, x^3]], R); M |
| 499 | Free module of degree 2 and rank 2 over |
| 500 | Univariate Polynomial Ring in x over Rational Field |
| 501 | Echelon basis matrix: |
| 502 | [ 1/x x^3] |
| 503 | [ 0 x^5 - x^2 - 1] |
| 504 | sage: M.basis()[0][0].parent() |
| 505 | Fraction Field of Univariate Polynomial Ring in x over Rational Field |
| 506 | |
| 507 | A base ring can be inferred if the generators are given as a |
| 508 | list of vectors. :: |
| 509 | |
| 510 | sage: span([vector(QQ, [1,2,3]), vector(QQ, [4,5,6])]) |
| 511 | Vector space of degree 3 and dimension 2 over Rational Field |
| 512 | Basis matrix: |
| 513 | [ 1 0 -1] |
| 514 | [ 0 1 2] |
| 515 | sage: span([vector(QQ, [1,2,3]), vector(ZZ, [4,5,6])]) |
| 516 | Vector space of degree 3 and dimension 2 over Rational Field |
| 517 | Basis matrix: |
| 518 | [ 1 0 -1] |
| 519 | [ 0 1 2] |
| 520 | sage: span([vector(ZZ, [1,2,3]), vector(ZZ, [4,5,6])]) |
| 521 | Free module of degree 3 and rank 2 over Integer Ring |
| 522 | Echelon basis matrix: |
| 523 | [1 2 3] |
| 524 | [0 3 6] |
| 525 | |