(* ::Package:: *)

(************************************************************************)
(* This file was generated automatically by the Mathematica front end.  *)
(* It contains Initialization cells from a Notebook file, which         *)
(* typically will have the same name as this file except ending in      *)
(* ".nb" instead of ".m".                                               *)
(*                                                                      *)
(* This file is intended to be loaded into the Mathematica kernel using *)
(* the package loading commands Get or Needs.  Doing so is equivalent   *)
(* to using the Evaluate Initialization Cells menu command in the front *)
(* end.                                                                 *)
(*                                                                      *)
(* DO NOT EDIT THIS FILE.  This entire file is regenerated              *)
(* automatically each time the parent Notebook file is saved in the     *)
(* Mathematica front end.  Any changes you make to this file will be    *)
(* overwritten.                                                         *)
(************************************************************************)



BlockHouse[V_,0]:= Module[
{n=Length[V]},
SparseArray[Band[{1,1}]->1,{n,n}]-2V.Inverse[Transpose[V].V].Transpose[V]
]

BlockHouse[V_,1]:= Module[
{n=Length[V]},
SparseArray[Band[{1,1}]->1,{n,n}]-2V.PseudoInverse[V]
]


HouseholderV[A1A2_,0]:= Module[
{A1,A2, m,r,P,\[Lambda],X},
{m,r}=Dimensions[A1A2];
A1=Take[A1A2,r];A2=Drop[A1A2,r];
P=A2.Inverse[A1]; POut=P;
{\[Lambda],P}=Eigensystem[IdentityMatrix[r]+ Transpose[P].P];
X=Transpose[P].DiagonalMatrix[Sqrt[\[Lambda]]].P.A1;
ArrayFlatten[{{A1+X},{A2}}]
]

HouseholderV[A1A2_,1]:= Module[
{A1,A2, m,r,P,\[Lambda],X},
{m,r}=Dimensions[A1A2];
A1=Take[A1A2,r];A2=Drop[A1A2,r];
P=A2.Inverse[A1];
X=MatrixPower[IdentityMatrix[r]+ Transpose[P].P,1/2].A1;
ArrayFlatten[{{A1+X},{A2}}]
]



