示例#1
0
文件: Amos.cs 项目: Xornent/simula
            // Return Exp(-Abs(y)) * J(v, z) where y = z.Imaginary
            public static Complex ScaledCbesj(double v, Complex z)
            {
                if (double.IsNaN(v) || double.IsNaN(z.Real) || double.IsNaN(z.Imaginary))
                {
                    return(new Complex(double.NaN, double.NaN));
                }

                int sign = 1;

                if (v < 0)
                {
                    v    = -v;
                    sign = -1;
                }

                int n    = 1;
                int kode = 2;
                int nz   = 0;
                int ierr = 0;

                double[] cyjr = new double[n];
                double[] cyji = new double[n];
                for (int i = 0; i < n; i++)
                {
                    cyjr[i] = double.NaN;
                    cyji[i] = double.NaN;
                }

                AmosHelper.zbesj(z.Real, z.Imaginary, v, kode, n, cyjr, cyji, ref nz, ref ierr);
                Complex cyj = new Complex(cyjr[0], cyji[0]);

                if (sign == -1)
                {
                    if (!ReflectJY(ref cyj, v))
                    {
                        double[] cyyr   = new double[n];
                        double[] cyyi   = new double[n];
                        double[] cworkr = new double[n];
                        double[] cworki = new double[n];
                        for (int i = 0; i < n; i++)
                        {
                            cyyr[i]   = double.NaN;
                            cyyi[i]   = double.NaN;
                            cworkr[i] = double.NaN;
                            cworki[i] = double.NaN;
                        }

                        AmosHelper.zbesy(z.Real, z.Imaginary, v, kode, n, cyyr, cyyi, ref nz, cworkr, cworki, ref ierr);
                        Complex cyy = new Complex(cyyr[0], cyyi[0]);

                        cyj = RotateJY(cyj, cyy, v);
                    }
                }
                return(cyj);
            }
示例#2
0
文件: Amos.cs 项目: Xornent/simula
            // Return Y(v, z)
            public static Complex Cbesy(double v, Complex z)
            {
                if (double.IsNaN(v) || double.IsNaN(z.Real) || double.IsNaN(z.Imaginary))
                {
                    return(new Complex(double.NaN, double.NaN));
                }

                int sign = 1;

                if (v < 0)
                {
                    v    = -v;
                    sign = -1;
                }

                int     n    = 1;
                int     kode = 1;
                int     nz   = 0;
                int     ierr = 0;
                Complex cyy;

                if (z.Real == 0 && z.Imaginary == 0)
                {
                    //overflow
                    cyy = new Complex(double.NegativeInfinity, 0);
                }
                else
                {
                    double[] cyyr   = new double[n];
                    double[] cyyi   = new double[n];
                    double[] cworkr = new double[n];
                    double[] cworki = new double[n];
                    for (int i = 0; i < n; i++)
                    {
                        cyyr[i]   = double.NaN;
                        cyyi[i]   = double.NaN;
                        cworkr[i] = double.NaN;
                        cworki[i] = double.NaN;
                    }

                    AmosHelper.zbesy(z.Real, z.Imaginary, v, kode, n, cyyr, cyyi, ref nz, cworkr, cworki, ref ierr);
                    cyy = new Complex(cyyr[0], cyyi[0]);

                    if (ierr == 2)
                    {
                        if (z.Real >= 0 && z.Imaginary == 0)
                        {
                            //overflow
                            cyy = new Complex(double.NegativeInfinity, 0);
                        }
                    }
                }

                if (sign == -1)
                {
                    if (!ReflectJY(ref cyy, v))
                    {
                        double[] cyjr = new double[n];
                        double[] cyji = new double[n];
                        for (int i = 0; i < n; i++)
                        {
                            cyjr[i] = double.NaN;
                            cyji[i] = double.NaN;
                        }

                        AmosHelper.zbesj(z.Real, z.Imaginary, v, kode, n, cyjr, cyji, ref nz, ref ierr);
                        Complex cyj = new Complex(cyjr[0], cyji[0]);

                        cyy = RotateJY(cyy, cyj, -v);
                    }
                }
                return(cyy);
            }