First time here? Check out the FAQ!

Ask Your Question
0

Cannot create Matrix with Variables over modulo ring

asked 3 years ago

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?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 3 years ago

Max Alekseyev gravatar image

updated 3 years ago

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)
Preview: (hide)
link

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: 3 years ago

Seen: 197 times

Last updated: Nov 12 '21