Exemplo n.º 1
0
        public static Matrix CalculateHouseholderTransform(Vector x)
        {
            if (x.EuclidianNorm() == 0) {
                return MatrixFactory.IdentityMatrix(x.Height);
            }

            double a = x[0].R == 0 ? x.EuclidianNorm() : Math.Sign(x[0].R) * x.EuclidianNorm();
            Vector u = x + a * Vector.Ei(x.Size, 0);
            Vector v = u / u.EuclidianNorm();

            Complex w = (x.ConjugateTranspose() * v).ToComplexNumber() / (v.ConjugateTranspose() * x).ToComplexNumber();
            return (MatrixFactory.IdentityMatrix(x.Height) - (1.0 + w) * v * v.ConjugateTranspose());
        }