示例#1
0
        public static WWComplex[] Add(WWComplex[] a, WWComplex[] b)
        {
            if (a.Length != b.Length)
            {
                throw new ArgumentException("input array length mismatch");
            }

            var c = new WWComplex[a.Length];

            for (int i = 0; i < a.Length; ++i)
            {
                c[i] = WWComplex.Add(a[i], b[i]);
            }
            return(c);
        }
示例#2
0
        public WWComplex[] ConvolutionBruteForce(WWComplex[] f, WWComplex[] g)
        {
            var r = new WWComplex[f.Length + g.Length - 1];

            Parallel.For(0, r.Length, i => {
                WWComplex v = new WWComplex();

                for (int j = 0; j < f.Length; ++j)
                {
                    int fpos = f.Length - j - 1;
                    int gpos = i + j - (f.Length - 1);
                    v.Add(WWComplex.Mul(Get(f, fpos), Get(g, gpos)));
                }
                r[i] = v;
            });

            return(r);
        }
示例#3
0
 public static WWComplex Add(WWComplex a, WWComplex b)
 {
     var r = new WWComplex(a);
     r.Add(b);
     return r;
 }