Reputation: 945
I am computing the null space of a matrix A(m,n) with gsl library in c.
Following the documentation of singular value decomposition (SVD) function in gsl such as A = USVt
" For a rank-deficient matrix, the null space of A is given by the columns of V corresponding to the zero singular values. "
The corresponding function is
int gsl_linalg_SV_decomp(gsl_matrix * A, gsl_matrix * V, gsl_vector * S, gsl_vector * work)
the syntax is the following:
#include <gsl/gsl_linalg.h>
#include <gsl/gsl_blas.h>
#include <stdio.h>
#include <stdlib.h>
...
int main(int argc, char **argv){
...
gsl_linalg_SV_decomp(A,V,S,work);
return 0;
}
I get the following error
gsl: svd.c:60: ERROR: svd of MxN matrix, M<N, is not implemented
Default GSL error handler invoked
Indeed A has M < N.
Are you aware of another library that would compute the Null space of a matrix of M < N ? Is there a workaround with gsl?
Upvotes: 0
Views: 557
Reputation: 4431
You can do this by computing the SVD of A' (A transpose) rather than A. The null space of A is spanned by the left singular vectors corresponding to zero singular values.
For any matrix B, just as the right singular vectors corresponding to zero singular values span the null-space of B, the left singular vectors corresponding to non-zero singular vectors span the range of B.
So if we do an SVD of A', with
A' = U*S*V'
The range of A' is spanned by the columns of U corresponding to non-zero singular vectors. But the null-space of A is the set of vectors perpendicular to the range of A'. Therefore the null-space of A is spanned by the columns of U correspeonding to zero singular values.
Upvotes: 1