# Affine Subspaces of a Vector Space¶

An affine subspace of a vector space is a translation of a linear subspace. The affine subspaces here are only used internally in hyperplane arrangements. You should not use them for interactive work or return them to the user.

EXAMPLES:

```sage: from sage.geometry.hyperplane_arrangement.affine_subspace import AffineSubspace
sage: a = AffineSubspace([1,0,0,0], QQ^4)
sage: a.dimension()
4
sage: a.point()
(1, 0, 0, 0)
sage: a.linear_part()
Vector space of dimension 4 over Rational Field
sage: a
Affine space p + W where:
p = (1, 0, 0, 0)
W = Vector space of dimension 4 over Rational Field
sage: b = AffineSubspace((1,0,0,0), matrix(QQ, [[1,2,3,4]]).right_kernel())
sage: c = AffineSubspace((0,2,0,0), matrix(QQ, [[0,0,1,2]]).right_kernel())
sage: b.intersection(c)
Affine space p + W where:
p = (-3, 2, 0, 0)
W = Vector space of degree 4 and dimension 2 over Rational Field
Basis matrix:
[  1   0  -1 1/2]
[  0   1  -2   1]
sage: b < a
True
sage: c < b
False
sage: A = AffineSubspace([8,38,21,250], VectorSpace(GF(19),4))
sage: A
Affine space p + W where:
p = (8, 0, 2, 3)
W = Vector space of dimension 4 over Finite Field of size 19
```
class sage.geometry.hyperplane_arrangement.affine_subspace.AffineSubspace(p, V)

An affine subspace.

INPUT:

• `p` – list/tuple/iterable representing a point on the affine space

• `V` – vector subspace

OUTPUT:

Affine subspace parallel to `V` and passing through `p`.

EXAMPLES:

```sage: from sage.geometry.hyperplane_arrangement.affine_subspace import AffineSubspace
sage: a = AffineSubspace([1,0,0,0], VectorSpace(QQ,4))
sage: a
Affine space p + W where:
p = (1, 0, 0, 0)
W = Vector space of dimension 4 over Rational Field
```
dimension()

Return the dimension of the affine space.

OUTPUT:

An integer.

EXAMPLES:

```sage: from sage.geometry.hyperplane_arrangement.affine_subspace import AffineSubspace
sage: a = AffineSubspace([1,0,0,0],VectorSpace(QQ,4))
sage: a.dimension()
4
```
intersection(other)

Return the intersection of `self` with `other`.

INPUT:

OUTPUT:

A new affine subspace, (or `None` if the intersection is empty).

EXAMPLES:

```sage: from sage.geometry.hyperplane_arrangement.affine_subspace import AffineSubspace
sage: V = VectorSpace(QQ,3)
sage: U = V.subspace([(1,0,0), (0,1,0)])
sage: W = V.subspace([(0,1,0), (0,0,1)])
sage: A = AffineSubspace((0,0,0), U)
sage: B = AffineSubspace((1,1,1), W)
sage: A.intersection(B)
Affine space p + W where:
p = (1, 1, 0)
W = Vector space of degree 3 and dimension 1 over Rational Field
Basis matrix:
[0 1 0]
sage: C = AffineSubspace((0,0,1), U)
sage: A.intersection(C)
sage: C = AffineSubspace((7,8,9), U.complement())
sage: A.intersection(C)
Affine space p + W where:
p = (7, 8, 0)
W = Vector space of degree 3 and dimension 0 over Rational Field
Basis matrix:
[]
sage: A.intersection(C).intersection(B)

sage: D = AffineSubspace([1,2,3], VectorSpace(GF(5),3))
sage: E = AffineSubspace([3,4,5], VectorSpace(GF(5),3))
sage: D.intersection(E)
Affine space p + W where:
p = (3, 4, 0)
W = Vector space of dimension 3 over Finite Field of size 5
```
linear_part()

Return the linear part of the affine space.

OUTPUT:

A vector subspace of the ambient space.

EXAMPLES:

```sage: from sage.geometry.hyperplane_arrangement.affine_subspace import AffineSubspace
sage: A = AffineSubspace([2,3,1], matrix(QQ, [[1,2,3]]).right_kernel())
sage: A.linear_part()
Vector space of degree 3 and dimension 2 over Rational Field
Basis matrix:
[   1    0 -1/3]
[   0    1 -2/3]
sage: A.linear_part().ambient_vector_space()
Vector space of dimension 3 over Rational Field
```
point()

Return a point `p` in the affine space.

OUTPUT:

A point of the affine space as a vector in the ambient space.

EXAMPLES:

```sage: from sage.geometry.hyperplane_arrangement.affine_subspace import AffineSubspace
sage: A = AffineSubspace([2,3,1], VectorSpace(QQ,3))
sage: A.point()
(2, 3, 1)
```