Example #1
0
        public DenseMatrixComplex smallestEigPositiveDefinite(ref SparseMatrixComplex A, ref SparseMatrixComplex B, ref DenseMatrixComplex x)
        {
            LinearSystemGenericByLib.Instance.FactorizationLU(ref A);
            int n = A.Length();

            DenseMatrixComplex e = new DenseMatrixComplex(n, 1);

            e.Fill(new Complex(1, 0));

            Complex dot  = e.Dot(B * e);
            double  norm = Math.Sqrt(dot.Norm());

            e /= new Complex(norm, 0);

            //Iteratation
            for (int i = 0; i < MaxEigIter; i++)
            {
                x  = B * x;
                x  = LinearSystemGenericByLib.Instance.SolveByFactorizedLU(ref x);
                x -= x.Dot(B * e) * e;

                double newNorm = Math.Sqrt(x.Dot(B * x).Norm());
                x /= new Complex(newNorm, 0);
            }

            LinearSystemGenericByLib.Instance.FreeSolverLUComplex();
            return(x);
        }