# Revision history [back]

First, note n by m matrices over a ring form a ring only if n and m are equal.

Example:

sage: MatrixSpace(ZZ, 2, 3) in Rings
False
sage: MatrixSpace(ZZ, 2) in Rings
True


Now in the case of square matrices, one way to answer your question is as follows.

sage: R.<x> = ZZ[]
sage: I = R.ideal([2, x])
sage: M = MatrixSpace(R, n)
sage: IM_gens = [a * m for a in I.gens() for m in M.gens()]
sage: IM = M.ideal(IM_gens)


This gives us the following.

sage: R
Univariate Polynomial Ring in x over Integer Ring
sage: I
Ideal (2, x) of Univariate Polynomial Ring in x over Integer Ring
sage: M
Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in x over Integer Ring
sage: IM_gens
[
[2 0]  [0 2]  [0 0]  [0 0]  [x 0]  [0 x]  [0 0]  [0 0]
[0 0], [0 0], [2 0], [0 2], [0 0], [0 0], [x 0], [0 x]
]
sage: IM

Twosided Ideal
(
[2 0]
[0 0],

[0 2]
[0 0],

[0 0]
[2 0],

[0 0]
[0 2],

[x 0]
[0 0],

[0 x]
[0 0],

[0 0]
[x 0],

[0 0]
[0 x]
)
of Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in x over Integer Ring


First, note n by m matrices over a ring form a ring only if n and m are equal.

Example:

sage: MatrixSpace(ZZ, 2, 3) in Rings
False
sage: MatrixSpace(ZZ, 2) in Rings
True


Now in the case of square matrices, one way to answer your question is as follows.

sage: R.<x> = ZZ[]
sage: I = R.ideal([2, x])
sage: M = MatrixSpace(R, n)
2)
sage: IM_gens = [a * m for a in I.gens() for m in M.gens()]
sage: IM = M.ideal(IM_gens)


This gives us the following.

sage: R
Univariate Polynomial Ring in x over Integer Ring
sage: I
Ideal (2, x) of Univariate Polynomial Ring in x over Integer Ring
sage: M
Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in x over Integer Ring
sage: IM_gens
[
[2 0]  [0 2]  [0 0]  [0 0]  [x 0]  [0 x]  [0 0]  [0 0]
[0 0], [0 0], [2 0], [0 2], [0 0], [0 0], [x 0], [0 x]
]
sage: IM

Twosided Ideal
(
[2 0]
[0 0],

[0 2]
[0 0],

[0 0]
[2 0],

[0 0]
[0 2],

[x 0]
[0 0],

[0 x]
[0 0],

[0 0]
[x 0],

[0 0]
[0 x]
)
of Full MatrixSpace of 2 by 2 dense matrices over Univariate Polynomial Ring in x over Integer Ring