Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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.

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

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

click to hide/show revision 4
retagged

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