python - Finding the nullspace of a matrix with QR factorization -
so have matrix x
, want know basis nullspace. i've seen suggestion qr decomposition give where, if x
m × n
q
m × n
, if write q = [q1, q2]
q1
m × m
q2
have columns basis nullspace of x
. however, x
4 × 4
q
same, , can't split proper pieces, don't seem able find vectors in nullspace.
am misunderstanding how basis nullspace qr decomposition, or not work square matrices have non-trivial kernels?
also, there way more efficiently or straight find basis null space?
here actual total code i'm running:
import sympy sp c1 = [2, 0, 0, 0] c2 = [1, 2, 0, 0] c3 = [0, 1, 2, 0] c4 = [0, 0, 0, 3] ul = [1, 1, 1, 1] = sp.matrix([ sp.matrix(c1).t, sp.matrix(c2).t, sp.matrix(c3).t, sp.matrix(c4).t ]).t u = sp.matrix(ul) m = u.row_join(a*u).row_join(a**2*u).row_join(a**3*u).row_join(a**4*u) coefs = m.rref()[0].col(4) x = sp.symbol('x') p = 1 in range(4): p = p - coefs[3-i]*x**(i+1) sol = sp.solve(p,x) qs = [] in range(2): q,r = ((a-sol[i]*sp.eye(4)).t).qrdecomposition() qs.append(q)
python matrix linear-algebra
No comments:
Post a Comment