Create single-column matrix (aka. column vector)
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.
UPDATE: Bugfix ticket submitted here: https://trac.sagemath.org/ticket/34821
Looks like a bug. As a workaround, you could create an
r x 3r
matrix and take its transpose; that seems to work better.Thanks for the idea @John Palmieri, it should work, yes. I wanted to know if there's something I'm missing but folks here also say it's a bug. I'll go with @Emmanuel Charpentier's answer and I'll try to submit a ticket.