Пример #1
0
        public static IComplexFloatMatrix AU(IComplexFloatMatrix A, IROComplexFloatVector u, int r1, int r2, int c1, int c2, IComplexFloatVector v)
        {
            if (r2 < r1 || c2 < c1)
            {
                return(A);
            }

            if (c2 - c1 + 1 > u.Length)
            {
                throw new ArgumentException("Householder vector too short.", "u");
            }

            if (r2 - r1 + 1 > v.Length)
            {
                throw new ArgumentException("Work vector too short.", "v");
            }

            for (int i = r1; i <= r2; i++)
            {
                v[i - r1] = ComplexFloat.Zero;
                for (int j = c1; j <= c2; j++)
                {
                    v[i - r1] = new ComplexFloat(v[i - r1].Real + A[i, j].Real * u[j - c1].Real - A[i, j].Imag * u[j - c1].Imag,
                                                 v[i - r1].Imag + A[i, j].Real * u[j - c1].Imag + A[i, j].Imag * u[j - c1].Real);
                }
            }
            for (int i = r1; i <= r2; i++)
            {
                for (int j = c1; j <= c2; j++)
                {
                    A[i, j] = new ComplexFloat(A[i, j].Real - v[i - r1].Real * u[j - c1].Real - v[i - r1].Imag * u[j - c1].Imag,
                                               A[i, j].Imag + v[i - r1].Real * u[j - c1].Imag - v[i - r1].Imag * u[j - c1].Real);
                }
            }
            return(A);
        }
Пример #2
0
		public static IComplexFloatMatrix AU(IComplexFloatMatrix A, IROComplexFloatVector u, int r1, int r2, int c1, int c2, IComplexFloatVector v)
		{
			if (r2 < r1 || c2 < c1)
			{
				return A;
			}

			if (c2 - c1 + 1 > u.Length)
			{
				throw new ArgumentException("Householder vector too short.", "u");
			}

			if (r2 - r1 + 1 > v.Length)
			{
				throw new ArgumentException("Work vector too short.", "v");
			}

			for (int i = r1; i <= r2; i++)
			{
				v[i - r1] = ComplexFloat.Zero;
				for (int j = c1; j <= c2; j++)
				{
					v[i - r1] = new ComplexFloat(v[i - r1].Real + A[i, j].Real * u[j - c1].Real - A[i, j].Imag * u[j - c1].Imag,
						v[i - r1].Imag + A[i, j].Real * u[j - c1].Imag + A[i, j].Imag * u[j - c1].Real);
				}
			}
			for (int i = r1; i <= r2; i++)
			{
				for (int j = c1; j <= c2; j++)
				{
					A[i, j] = new ComplexFloat(A[i, j].Real - v[i - r1].Real * u[j - c1].Real - v[i - r1].Imag * u[j - c1].Imag,
						A[i, j].Imag + v[i - r1].Real * u[j - c1].Imag - v[i - r1].Imag * u[j - c1].Real);
				}
			}
			return A;
		}