I have a function that creates matrices of dimension $3r\times r$ with variables:
def create_matrix_with_variables(r):
m=3*r
variable_names_string=['b_%d_%d' %(i,j) for (i,j) in cartesian_product([range(1,m+1),range(1,r+1)])]
parent_ring=ZZ[variable_names_string]
betas=list(parent_ring.variable_names())
beta=matrix(parent_ring,m,r,betas)
return beta
create_matrix_with_variables(2)
create_matrix_with_variables(1)
It works for $r>1$ but fails for $r=1$. I would love to post a screenshot but my karma is not enough. How do I do this correctly for $r=1$? I am using Sage 9.7 on mac in jupyter. Thanks.