示例#1
0
        public ComplexCapsule GetWalsh()
        {
            DataCapsule    loaded = SerializationLogics.Deserialize();
            List <Complex> result = new List <Complex>();

            Complex sum;

            int m = 0;

            while (Math.Pow(2, m) <= loaded.XValues.Count)
            {
                m++;
            }
            loaded.Take((int)Math.Pow(2, --m));

            double[][] matrix = TransformationsLogics.GetMatrix(m);

            for (int i = 0; i < loaded.XValues.Count; i++)
            {
                sum = Complex.Zero;
                for (int j = 0; j < Math.Pow(2, m); j++)
                {
                    sum += loaded.YValues[j] * matrix[i][j];
                }

                sum /= loaded.YValues.Count;//(double)(Math.Pow(Math.Sqrt(2.0), m));

                result.Add(sum);
            }

            return(new ComplexCapsule(loaded.XValues, result, loaded.SamplingFrequency));
        }
示例#2
0
        public ComplexCapsule GetFourier()
        {
            DataCapsule loaded = SerializationLogics.Deserialize();

            List <Complex> results = new List <Complex>();
            Complex        sum;

            int m = 0;

            while (Math.Pow(2, m) <= loaded.XValues.Count)
            {
                m++;
            }
            loaded.Take((int)Math.Pow(2, --m));

            for (int i = 0; i < loaded.XValues.Count; i++)
            {
                sum = Complex.Zero;

                for (int k = 0; k < loaded.XValues.Count; k++)
                {
                    sum += loaded.YValues[k] * Complex.Exp(new Complex(0, -2 * Math.PI * i * k / loaded.XValues.Count));
                }

                results.Add(sum / loaded.XValues.Count);
            }

            return(new ComplexCapsule(loaded.XValues, results, loaded.SamplingFrequency));
        }
示例#3
0
        public ComplexCapsule GetFastFourier()
        {
            DataCapsule loaded = SerializationLogics.Deserialize();

            TransformationsLogics logics = new TransformationsLogics();

            List <Complex> transformed = new List <Complex>();
            int            N           = loaded.XValues.Count;

            transformed = logics.SwitchSamples(loaded.YValues);
            return(new ComplexCapsule(loaded.XValues.Take(transformed.Count).ToList(), transformed.Select(c => c / N).ToList(), loaded.SamplingFrequency));
        }
示例#4
0
        internal IChartValues Filter(int m, int cutOffFrequency, int windowChoice, int filterChoice)
        {
            DataCapsule   loaded = SerializationLogics.Deserialize();
            List <double> factors, filtered;

            switch (filterChoice)
            {
            case 0:
                factors = FilterLogics.LowFilter(m, loaded.SamplingFrequency / cutOffFrequency);
                break;

            case 1:
                factors = FilterLogics.MediumFilter(FilterLogics.LowFilter(m, (loaded.SamplingFrequency / (loaded.SamplingFrequency / 4.0 - cutOffFrequency))));
                break;

            case 2:
                factors = FilterLogics.HighFilter(FilterLogics.LowFilter(m, (loaded.SamplingFrequency / (loaded.SamplingFrequency / 2.0 - cutOffFrequency))));
                break;

            default:
                throw new Exception("The filter combobox is out of its boundries.");
            }

            switch (windowChoice)
            {
            case 0:
                filtered = factors;
                break;

            case 1:
                filtered = FilterLogics.HammingWindow(factors);
                break;

            case 2:
                filtered = FilterLogics.HanningWindow(factors);
                break;

            case 3:
                filtered = FilterLogics.BlackmanWindow(factors);
                break;

            default:
                throw new Exception("The window combobox is out of its boundries.");
            }

            return(loaded.Weave(filtered).GetValues());
        }
示例#5
0
        public ComplexCapsule GetFastWalsh()
        {
            DataCapsule    loaded = SerializationLogics.Deserialize();
            List <Complex> result = new List <Complex>();

            Complex a, b;

            int m = 0;

            while (Math.Pow(2, m) <= loaded.XValues.Count)
            {
                m++;
            }
            loaded.Take((int)Math.Pow(2, --m));

            for (int h = 1; h < loaded.XValues.Count; h *= 2)
            {
                for (int i = 0; i < loaded.XValues.Count; i += h * 2)
                {
                    for (int j = i; j < i + h; j++)
                    {
                        a = loaded.YValues[j];
                        b = loaded.YValues[j + h];

                        loaded.YValues[j]     = a + b;
                        loaded.YValues[j + h] = a - b;
                    }
                }
            }

            for (int i = 0; i < loaded.XValues.Count; i++)
            {
                loaded.YValues[i] /= loaded.YValues.Count;
            }

            return(new ComplexCapsule(loaded.XValues, loaded.YValues, loaded.SamplingFrequency));
        }
示例#6
0
        internal IChartValues WeaveCorrelation()
        {
            DataCapsule[] loaded = SerializationLogics.LoadFiles();

            return(loaded[0].WeaveCorrelation(loaded[1]).GetValues());
        }
示例#7
0
        internal IChartValues Divide()
        {
            DataCapsule[] loaded = SerializationLogics.LoadFiles();

            return(loaded[0].Divide(loaded[1]).GetValues());
        }
示例#8
0
        internal IChartValues Multiply()
        {
            DataCapsule[] loaded = SerializationLogics.LoadFiles();

            return(loaded[0].Multiply(loaded[1]).GetValues());
        }
示例#9
0
        internal IChartValues Subtract()
        {
            DataCapsule[] loaded = SerializationLogics.LoadFiles();

            return(loaded[0].Subtract(loaded[1]).GetValues());
        }
示例#10
0
 internal DataCapsule Deserialize()
 {
     return(SerializationLogics.Deserialize());
 }
示例#11
0
 internal void Serialize(DataCapsule capsule)
 {
     SerializationLogics.Serialize(capsule);
 }