Ask Your Question
0

Cannot create Matrix with Variables over modulo ring

asked 2021-11-11 15:42:52 +0100

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?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-11-12 14:25:31 +0100

Max Alekseyev gravatar image

updated 2021-11-12 14:43:08 +0100

The variables you are trying to use in K are not in its ring R. Also, it's better to avoid dealing with symbolic ring (i.e. defining variables via var) whenever possible. A better way here is to define R as a polynomial ring in your variables like:

k_vars = [ ["k_{}_{}".format(u,v) for v in (1..2)] for u in (1..2) ]

R = PolynomialRing(IntegerModRing(22), sum(k_vars,[]) )
R._latex_names = sum( [["k_{{{},{}}}".format(u,v) for v in (1..2)] for u in (1..2)], [] )

K = matrix(R, k_vars)
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2021-11-11 15:42:52 +0100

Seen: 165 times

Last updated: Nov 12 '21