Re: [eigen] notes on Householder and Givens

[ Thread Index | Date Index | More Archives ]

OK, last email, i promise.

Actually even my last ei_compute_householder can be made to work with
zero branching, in the case of real numbers. This would be a nice
optimization in the case of real, small (fixed size...) SVD, which
you're interested in.

The idea is that for real numbers, " x0 / abs(x0) is just the sign of
x. And one can code a bitwise "sign" function that works without any
branching. It doesn't matter what happens around x0==0 as long as that
function always returns +1 or -1, because if x0 is near zero then both
x + norm(x) e0 and x - norm(x) e0 are good possible choices for v.

To summarize, in real case:

void ei_compute_householder(const Vector& x of size n, Householder *h)
 // compute natural householder vector v
 Vector v = x;
  v0 += sign(x0) * norm(x);

 Vector v_starting_with_1 = v/v0;

 h->essential = v_starting_with_1.end(n-1);
 h->beta = 2 / v_starting_with_1.squaredNorm();

in the complex case, sign(x0) could still return x0/abs(x0) if x0 is
not near 0, but there we must be careful if x0 is close to zero: some
branching is neeeded.


Mail converted by MHonArc 2.6.19+