Ask Your Question

Revision history [back]

Cannot create Matrix with Variables over modulo ring

The following code does not work in the official sage cell server at sagecell(.)sagemath(.)org.

R = IntegerModRing(22)
K=matrix(R, [[var("k_{}_{}".format(u,v), latex_name="k_{{{},{}}}".format(u,v)) for v in (1..2)] for u in (1..2)])
print(K)

It complains that the k_i_j cannot be converted to integer. It works without errors if the ring is not specified during the creation of the matrix:

K=matrix([[var("k_{}_{}".format(u,v), latex_name="k_{{{},{}}}".format(u,v)) for v in (1..2)] for u in (1..2)])

Where is the problem? Is there a way to denote the k_i_j as integers / elements of the modulo ring?