#!/usr/bin/python -Wall

# ================================================================
# John Kerl
# kerl.john.r@gmail.com
# 2007-01-12
#
# Computes a Householder transformation sending u hat to v hat.
# ================================================================
# This software is released under the terms of the GNU GPL.
# Please see LICENSE.txt in the same directory as this file.
# ================================================================

from __future__ import division # 1/2 = 0.5, not 0.
import sys
from sackmat_m import *

argc = len(sys.argv)
if (argc != 3):
	print >> sys.stderr, "Usage: %s {u file name} {v file name}" % (sys.argv[0])
	sys.exit(1)

u = read_column_vector(float, sys.argv[1])
v = read_column_vector(float, sys.argv[2])

uhat = vechat(u)
vhat = vechat(v)

a  = vecsub(uhat, vhat)

[Q, sign] = householder_vector_to_Q(a)
print_matrix(Q)
