1 | initial version |
Here is what I would do
def something(m, n):
in frontFor example:
def something(m, n):
x = lambda i: SR.var(f"x_{i}", latex_name=f"x_{{{i}}}")
X = vector([x(i) for i in [1 .. n]])
b = VectorSpace(QQ, m).random_element()
A = matrix(QQ, m, n)
A[0, :] = ones_matrix(1, n)
for i in [1 .. m - 2]:
A[i, i:i + 2] = ones_matrix(1, 2)
eq = [A[i]*X == b[i] for i in range(m)]
a = matrix([[e.lhs().coefficient(v) for v in X] for e in eq])
C = A.augment(b)
D = C.right_kernel()
return X, b, A, eq, a, C, D