Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c++ armadillo - calculating null space

Tags:

c++

armadillo

this is my first post here...

Is there any way to calculate a vector in the null space of another vector? I don't need the basis, just one vector in the null space will do.

I already tried using the solve() method -

colvec x(3);
x = solve(A,B);

where A is a 3x3 matrix of type mat -

2 2 2
3 3 3
4 4 4

and B is the zero vector of type colvec -

0
0
0

But the program terminates throwing the following error -

error: solve(): solution not found
terminate called after throwing an instance of 'std::runtime_error'
  what():

I have used the solve() method before and got perfect results, but it doesn't seem to work in this simple case. Is this because the equation has multiple solutions? If so, is there any workaround to this, any other way that I could get a vector in the null space?

Any help would be appreciated.

Edit :

I tried the svd(mat U, vec s, mat V, mat X, method = "standard") method and I got the null space of X from the columns of V. I was just wondering if there is any way to improve the precision of the answer.
Thanks!

like image 847
user1673471 Avatar asked Nov 09 '13 20:11

user1673471


1 Answers

In recent version of the armadillo library you can find the orthonormal basis of the null space of matrix using the null() function. See the documentation at http://arma.sourceforge.net/docs.html#null. The functionality was added in version 5.400 (August 2015).

like image 77
Svaberg Avatar answered Sep 30 '22 02:09

Svaberg