示例#1
0
        private double abs(double real, double imag)
        {
            double temp;

            if (real < 0)
            {
                real = -real;
            }

            if (imag < 0)
            {
                imag = -imag;
            }

            if (imag > real)
            {
                temp = real;
                real = imag;
                imag = temp;
            }

            if ((real + imag) == real)
            {
                return(real);
            }

            temp = imag / real;
            temp = real * Math.Sqrt(1.0 + temp * temp);

            return(temp);
        }
示例#2
0
        internal static long kleinsterTeiler(long X, long start)
        {
            long stop = ( long )Math.ceil(Math.Sqrt(( double )X));

            if (start > stop)
            {
                return(X);
            }

            long b = start / 30L;

            b *= 30L;

            long m = start % 30L;

            int i = 0;

            while (m > mod[i])
            {
                i++;
            }

            while (start <= stop)
            {
                if (Session.Proc.CheckInterrupt())
                {
                    return(-1L);
                }

                if (X % start == 0)
                {
                    return(start);
                }

                i++;

                if (i >= mod.Length)
                {
                    i     = 0;
                    b    += 30L;
                    start = b;
                }

                start += moddif[i];
            }

            return(X);
        }
示例#3
0
        public override double Norm()
        {
            double r;

            if (Math.abs(Re) > Math.abs(Im))
            {
                r = Im / Re;
                r = Math.abs(Re) * Math.Sqrt(1 + r * r);
            }
            else if (Im != 0)
            {
                r = Re / Im;
                r = Math.abs(Im) * Math.Sqrt(1 + r * r);
            }
            else
            {
                r = 0.0;
            }

            return(r);
        }