Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Transform a list of commands in a program

I have that list of commands

X = [SR.var("x%d"%i) for i in [1..n]]; b = vector(random_matrix(QQ,1,m)[0]); A = matrix(QQ,m,n);
A[0, -n:] = ones_matrix(1,n); 
for i in [1..m-2]: 
    A[i, i:i+2] = ones_matrix(1,2); eq = [A[i]*vector(X) == b[i] for i in range(m)] ;  a = matrix([[e.lhs().coefficient(v) for v in X] for eqin eq]) ; C= A.augment(b); D = C.right_kernel()

The list os commands works if you choose m and n properly, but that is not practical.