Exemplo n.º 1
0
    internal virtual double z_abs(doublecomplex z)
    {
        double temp, real, imag;

        real = z.r;
        imag = z.i;

        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);
    }
Exemplo n.º 2
0
    internal static void pqsolve(double p, double q, double[] r, double[] i)
    {
        p = -p / 2.0;
        q = p * p - q;

        if (q >= 0)
        {
            // TODO: Check this
            q    = Math.Sqrt(q);
            r[0] = p + q;
            i[0] = 0.0;
            r[1] = p - q;
            i[1] = 0.0;
        }
        else
        {
            // TODO: Check this
            q    = Math.Sqrt(-q);
            r[0] = p;
            i[0] = q;
            r[1] = p;
            i[1] = -q;
        }
    }