# Affine Groups#

AUTHORS:

• Volker Braun: initial version

class sage.groups.affine_gps.affine_group.AffineGroup(degree, ring)[source]#

An affine group.

The affine group $$\mathrm{Aff}(A)$$ (or general affine group) of an affine space $$A$$ is the group of all invertible affine transformations from the space into itself.

If we let $$A_V$$ be the affine space of a vector space $$V$$ (essentially, forgetting what is the origin) then the affine group $$\mathrm{Aff}(A_V)$$ is the group generated by the general linear group $$GL(V)$$ together with the translations. Recall that the group of translations acting on $$A_V$$ is just $$V$$ itself. The general linear and translation subgroups do not quite commute, and in fact generate the semidirect product

$\mathrm{Aff}(A_V) = GL(V) \ltimes V.$

As such, the group elements can be represented by pairs $$(A, b)$$ of a matrix and a vector. This pair then represents the transformation

$x \mapsto A x + b.$

We can also represent affine transformations as linear transformations by considering $$\dim(V) + 1$$ dimensional space. We take the affine transformation $$(A, b)$$ to

$\begin{split}\begin{pmatrix} A & b \\ 0 & 1 \end{pmatrix}\end{split}$

and lifting $$x = (x_1, \ldots, x_n)$$ to $$(x_1, \ldots, x_n, 1)$$. Here the $$(n + 1)$$-th component is always 1, so the linear representations acts on the affine hyperplane $$x_{n+1} = 1$$ as affine transformations which can be seen directly from the matrix multiplication.

INPUT:

Something that defines an affine space. For example

• An affine space itself:

• A – affine space

• A vector space:

• V – a vector space

• Degree and base ring:

• degree – An integer. The degree of the affine group, that is, the dimension of the affine space the group is acting on.

• ring – A ring or an integer. The base ring of the affine space. If an integer is given, it must be a prime power and the corresponding finite field is constructed.

• var – (default: 'a') Keyword argument to specify the finite field generator name in the case where ring is a prime power.

EXAMPLES:

sage: F = AffineGroup(3, QQ); F
Affine Group of degree 3 over Rational Field
sage: F(matrix(QQ,[[1,2,3],[4,5,6],[7,8,0]]), vector(QQ,[10,11,12]))
[1 2 3]     [10]
x |-> [4 5 6] x + [11]
[7 8 0]     [12]
sage: F([[1,2,3],[4,5,6],[7,8,0]], [10,11,12])
[1 2 3]     [10]
x |-> [4 5 6] x + [11]
[7 8 0]     [12]
sage: F([1,2,3,4,5,6,7,8,0], [10,11,12])
[1 2 3]     [10]
x |-> [4 5 6] x + [11]
[7 8 0]     [12]

>>> from sage.all import *
>>> F = AffineGroup(Integer(3), QQ); F
Affine Group of degree 3 over Rational Field
>>> F(matrix(QQ,[[Integer(1),Integer(2),Integer(3)],[Integer(4),Integer(5),Integer(6)],[Integer(7),Integer(8),Integer(0)]]), vector(QQ,[Integer(10),Integer(11),Integer(12)]))
[1 2 3]     [10]
x |-> [4 5 6] x + [11]
[7 8 0]     [12]
>>> F([[Integer(1),Integer(2),Integer(3)],[Integer(4),Integer(5),Integer(6)],[Integer(7),Integer(8),Integer(0)]], [Integer(10),Integer(11),Integer(12)])
[1 2 3]     [10]
x |-> [4 5 6] x + [11]
[7 8 0]     [12]
>>> F([Integer(1),Integer(2),Integer(3),Integer(4),Integer(5),Integer(6),Integer(7),Integer(8),Integer(0)], [Integer(10),Integer(11),Integer(12)])
[1 2 3]     [10]
x |-> [4 5 6] x + [11]
[7 8 0]     [12]


Instead of specifying the complete matrix/vector information, you can also create special group elements:

sage: F.linear([1,2,3,4,5,6,7,8,0])
[1 2 3]     [0]
x |-> [4 5 6] x + [0]
[7 8 0]     [0]
sage: F.translation([1,2,3])
[1 0 0]     [1]
x |-> [0 1 0] x + [2]
[0 0 1]     [3]

>>> from sage.all import *
>>> F.linear([Integer(1),Integer(2),Integer(3),Integer(4),Integer(5),Integer(6),Integer(7),Integer(8),Integer(0)])
[1 2 3]     [0]
x |-> [4 5 6] x + [0]
[7 8 0]     [0]
>>> F.translation([Integer(1),Integer(2),Integer(3)])
[1 0 0]     [1]
x |-> [0 1 0] x + [2]
[0 0 1]     [3]


Some additional ways to create affine groups:

sage: A = AffineSpace(2, GF(4,'a'));  A                                         # needs sage.rings.finite_rings
Affine Space of dimension 2 over Finite Field in a of size 2^2
sage: G = AffineGroup(A); G                                                     # needs sage.rings.finite_rings
Affine Group of degree 2 over Finite Field in a of size 2^2
sage: G is AffineGroup(2,4)  # shorthand                                        # needs sage.rings.finite_rings
True

sage: V = ZZ^3;  V
Ambient free module of rank 3 over the principal ideal domain Integer Ring
sage: AffineGroup(V)
Affine Group of degree 3 over Integer Ring

>>> from sage.all import *
>>> A = AffineSpace(Integer(2), GF(Integer(4),'a'));  A                                         # needs sage.rings.finite_rings
Affine Space of dimension 2 over Finite Field in a of size 2^2
>>> G = AffineGroup(A); G                                                     # needs sage.rings.finite_rings
Affine Group of degree 2 over Finite Field in a of size 2^2
>>> G is AffineGroup(Integer(2),Integer(4))  # shorthand                                        # needs sage.rings.finite_rings
True

>>> V = ZZ**Integer(3);  V
Ambient free module of rank 3 over the principal ideal domain Integer Ring
>>> AffineGroup(V)
Affine Group of degree 3 over Integer Ring


REFERENCES:

Element[source]#

alias of AffineGroupElement

cardinality()[source]#

Return the cardinality of self.

EXAMPLES:

sage: # needs sage.libs.gap
sage: AffineGroup(6, GF(5)).cardinality()
172882428468750000000000000000

sage: AffineGroup(6, ZZ).cardinality()
+Infinity

>>> from sage.all import *
>>> # needs sage.libs.gap
>>> AffineGroup(Integer(6), GF(Integer(5))).cardinality()
172882428468750000000000000000

>>> AffineGroup(Integer(6), ZZ).cardinality()
+Infinity

degree()[source]#

Return the dimension of the affine space.

OUTPUT: integer

EXAMPLES:

sage: G = AffineGroup(6, GF(5))
sage: g = G.an_element()
sage: G.degree()
6
sage: G.degree() == g.A().nrows() == g.A().ncols() == g.b().degree()
True

>>> from sage.all import *
>>> G = AffineGroup(Integer(6), GF(Integer(5)))
>>> g = G.an_element()
>>> G.degree()
6
>>> G.degree() == g.A().nrows() == g.A().ncols() == g.b().degree()
True

linear(A)[source]#

Construct the general linear transformation by A.

INPUT:

• A – anything that determines a matrix

OUTPUT: The affine group element $$x \mapsto A x$$

EXAMPLES:

sage: G = AffineGroup(3, GF(5))
sage: G.linear([1,2,3,4,5,6,7,8,0])
[1 2 3]     [0]
x |-> [4 0 1] x + [0]
[2 3 0]     [0]

>>> from sage.all import *
>>> G = AffineGroup(Integer(3), GF(Integer(5)))
>>> G.linear([Integer(1),Integer(2),Integer(3),Integer(4),Integer(5),Integer(6),Integer(7),Integer(8),Integer(0)])
[1 2 3]     [0]
x |-> [4 0 1] x + [0]
[2 3 0]     [0]

linear_space()[source]#

Return the space of the affine transformations represented as linear transformations.

We can represent affine transformations $$Ax + b$$ as linear transformations by

$\begin{split}\begin{pmatrix} A & b \\ 0 & 1 \end{pmatrix}\end{split}$

and lifting $$x = (x_1, \ldots, x_n)$$ to $$(x_1, \ldots, x_n, 1)$$.

EXAMPLES:

sage: G = AffineGroup(3, GF(5))
sage: G.linear_space()
Full MatrixSpace of 4 by 4 dense matrices over Finite Field of size 5

>>> from sage.all import *
>>> G = AffineGroup(Integer(3), GF(Integer(5)))
>>> G.linear_space()
Full MatrixSpace of 4 by 4 dense matrices over Finite Field of size 5

matrix_space()[source]#

Return the space of matrices representing the general linear transformations.

OUTPUT: the parent of the matrices $$A$$ defining the affine group element $$Ax+b$$

EXAMPLES:

sage: G = AffineGroup(3, GF(5))
sage: G.matrix_space()
Full MatrixSpace of 3 by 3 dense matrices over Finite Field of size 5

>>> from sage.all import *
>>> G = AffineGroup(Integer(3), GF(Integer(5)))
>>> G.matrix_space()
Full MatrixSpace of 3 by 3 dense matrices over Finite Field of size 5

random_element()[source]#

Return a random element of this group.

EXAMPLES:

sage: # needs sage.libs.gap
sage: G = AffineGroup(4, GF(3))
sage: G.random_element()  # random
[2 0 1 2]     [1]
[2 1 1 2]     [2]
x |-> [1 0 2 2] x + [2]
[1 1 1 1]     [2]
sage: G.random_element() in G
True

>>> from sage.all import *
>>> # needs sage.libs.gap
>>> G = AffineGroup(Integer(4), GF(Integer(3)))
>>> G.random_element()  # random
[2 0 1 2]     [1]
[2 1 1 2]     [2]
x |-> [1 0 2 2] x + [2]
[1 1 1 1]     [2]
>>> G.random_element() in G
True

reflection(v)[source]#

Construct the Householder reflection.

A Householder reflection (transformation) is the affine transformation corresponding to an elementary reflection at the hyperplane perpendicular to $$v$$.

INPUT:

• v – a vector, or something that determines a vector

OUTPUT:

The affine group element that is just the Householder transformation (a.k.a. Householder reflection, elementary reflection) at the hyperplane perpendicular to $$v$$.

EXAMPLES:

sage: G = AffineGroup(3, QQ)
sage: G.reflection([1,0,0])
[-1  0  0]     [0]
x |-> [ 0  1  0] x + [0]
[ 0  0  1]     [0]
sage: G.reflection([3,4,-5])
[ 16/25 -12/25    3/5]     [0]
x |-> [-12/25   9/25    4/5] x + [0]
[   3/5    4/5      0]     [0]

>>> from sage.all import *
>>> G = AffineGroup(Integer(3), QQ)
>>> G.reflection([Integer(1),Integer(0),Integer(0)])
[-1  0  0]     [0]
x |-> [ 0  1  0] x + [0]
[ 0  0  1]     [0]
>>> G.reflection([Integer(3),Integer(4),-Integer(5)])
[ 16/25 -12/25    3/5]     [0]
x |-> [-12/25   9/25    4/5] x + [0]
[   3/5    4/5      0]     [0]

some_elements()[source]#

Return some elements.

EXAMPLES:

sage: # needs sage.libs.gap
sage: G = AffineGroup(4,5)
sage: G.some_elements()
[      [2 0 0 0]     [1]
[0 1 0 0]     [0]
x |-> [0 0 1 0] x + [0]
[0 0 0 1]     [0],
[2 0 0 0]     [0]
[0 1 0 0]     [0]
x |-> [0 0 1 0] x + [0]
[0 0 0 1]     [0],
[2 0 0 0]     [...]
[0 1 0 0]     [...]
x |-> [0 0 1 0] x + [...]
[0 0 0 1]     [...]]
sage: all(v.parent() is G for v in G.some_elements())
True

sage: G = AffineGroup(2,QQ)
sage: G.some_elements()
[      [1 0]     [1]
x |-> [0 1] x + [0],
...]

>>> from sage.all import *
>>> # needs sage.libs.gap
>>> G = AffineGroup(Integer(4),Integer(5))
>>> G.some_elements()
[      [2 0 0 0]     [1]
[0 1 0 0]     [0]
x |-> [0 0 1 0] x + [0]
[0 0 0 1]     [0],
[2 0 0 0]     [0]
[0 1 0 0]     [0]
x |-> [0 0 1 0] x + [0]
[0 0 0 1]     [0],
[2 0 0 0]     [...]
[0 1 0 0]     [...]
x |-> [0 0 1 0] x + [...]
[0 0 0 1]     [...]]
>>> all(v.parent() is G for v in G.some_elements())
True

>>> G = AffineGroup(Integer(2),QQ)
>>> G.some_elements()
[      [1 0]     [1]
x |-> [0 1] x + [0],
...]

translation(b)[source]#

Construct the translation by b.

INPUT:

• b – anything that determines a vector

OUTPUT: The affine group element $$x \mapsto x + b$$

EXAMPLES:

sage: G = AffineGroup(3, GF(5))
sage: G.translation([1,4,8])
[1 0 0]     [1]
x |-> [0 1 0] x + [4]
[0 0 1]     [3]

>>> from sage.all import *
>>> G = AffineGroup(Integer(3), GF(Integer(5)))
>>> G.translation([Integer(1),Integer(4),Integer(8)])
[1 0 0]     [1]
x |-> [0 1 0] x + [4]
[0 0 1]     [3]

vector_space()[source]#

Return the vector space of the underlying affine space.

EXAMPLES:

sage: G = AffineGroup(3, GF(5))
sage: G.vector_space()
Vector space of dimension 3 over Finite Field of size 5

>>> from sage.all import *
>>> G = AffineGroup(Integer(3), GF(Integer(5)))
>>> G.vector_space()
Vector space of dimension 3 over Finite Field of size 5