Ejemplo n.º 1
0
        public static ComplexDouble[] Transform(ComplexDouble[] input)
        {
            int length = input.Length;

            if (length == 1)
            {
                return new ComplexDouble[] { input[0] }
            }
            ;
            ComplexDouble[] evens = new ComplexDouble[length / 2];
            ComplexDouble[] odds  = new ComplexDouble[length / 2];
            for (int i = 0; i < length / 2; i++)
            {
                evens[i] = input[2 * i];
                odds[i]  = input[2 * i + 1];
            }
            ComplexDouble[] evensRes = Transform(evens);
            ComplexDouble[] oddsRes  = Transform(odds);
            for (int i = 0; i < length / 2; i++)
            {
                oddsRes[i] *= ComplexDouble.FromRF(1, -2 * Math.PI * i / length);
            }
            ComplexDouble[] res = new ComplexDouble[length];
            for (int i = 0; i < length / 2; i++)
            {
                res[i] = evensRes[i] + oddsRes[i];
                res[i + length / 2] = evensRes[i] - oddsRes[i];
            }
            return(res);
        }
Ejemplo n.º 2
0
        public static ComplexDouble FromRF(double r, double f)
        {
            ComplexDouble res = new ComplexDouble();

            res.a = r * Math.Cos(f);
            res.b = r * Math.Sin(f);
            return(res);
        }
Ejemplo n.º 3
0
        public static ComplexDouble FromAB(double a, double b)
        {
            ComplexDouble res = new ComplexDouble();

            res.a = a;
            res.b = b;
            return(res);
        }
Ejemplo n.º 4
0
 static ComplexDouble ImgExponent(double power)
 {
     return(ComplexDouble.FromRF(1, power));
 }
Ejemplo n.º 5
0
 public static ComplexDouble operator *(ComplexDouble z1, ComplexDouble z2)
 {
     return(ComplexDouble.FromAB(z1.a * z2.a - z1.b * z2.b, z1.a * z2.b + z2.a * z1.b));
 }
Ejemplo n.º 6
0
 public static ComplexDouble operator *(ComplexDouble z, double x)
 {
     return(ComplexDouble.FromAB(z.a * x, z.b * x));
 }
Ejemplo n.º 7
0
 public static ComplexDouble operator +(ComplexDouble z1, ComplexDouble z2)
 {
     return(ComplexDouble.FromAB(z1.a + z2.a, z1.b + z2.b));
 }
Ejemplo n.º 8
0
 public static ComplexDouble[] Transform(double[] input)
 {
     return(Transform(input.Select(x => ComplexDouble.FromAB(x, 0)).ToArray()));
 }