示例#1
0
        public void Test1()
        {
            double[] array = new double[2048];
            for (int i = 0; i < array.Length; i++)
            {
                array[i] = Math.Sign(Math.Sin(2.0 * Math.PI * (i + 0.5) / array.Length));
            }
            double[] copy = new double[array.Length];
            Array.Copy(array, copy, array.Length);

            Span <double> span = new Span <double>(array);

            WaveletTransformation.CDF53MultiLevel(span);

            Span <double> transformed = stackalloc double[array.Length];

            span.CopyTo(transformed);

            Console.WriteLine("Source,Transformed");
            for (int i = 0; i < array.Length; i++)
            {
                Console.WriteLine($"{copy[i]}, {transformed[i]}");
            }
            Assert.AreEqual(0, 0);
        }
示例#2
0
        public void TestCDF53ReversiblitySingle()
        {
            Single[] array = new Single[2048];
            for (int i = 0; i < array.Length; i++)
            {
                array[i] = (Single)Math.Sin(2.0 * Math.PI * i / array.Length);
            }
            Single[] copy = new Single[array.Length];
            Array.Copy(array, copy, array.Length);

            Span <Single> span = new Span <Single>(array);

            WaveletTransformation.CDF53MultiLevel(span);

            Span <Single> transformed = stackalloc Single[array.Length];

            span.CopyTo(transformed);

            WaveletTransformation.CDF53InverseMultiLevel(span);

            try
            {
                for (int i = 0; i < array.Length; i++)
                {
                    Assert.AreEqual(copy[i], array[i], -1.0 / short.MinValue);
                }
                Console.WriteLine("Source,Transformed");
                for (int i = 0; i < array.Length; i++)
                {
                    Console.WriteLine($"{copy[i]}, {transformed[i]}");
                }
            }
            catch (Exception)
            {
                Console.WriteLine("Expected,Actual");
                for (int i = 0; i < array.Length; i++)
                {
                    Console.WriteLine($"{copy[i]}, {array[i]}");
                }
                throw;
            }
        }
示例#3
0
        public void TestCDF53ReversibilityInt16()
        {
            Int16[] array = new Int16[2048];
            for (int i = 0; i < array.Length; i++)
            {
                array[i] = (Int16)(Int16.MaxValue * Math.Sin(2.0 * Math.PI * i / array.Length));
            }
            Int16[] copy = new Int16[array.Length];
            Array.Copy(array, copy, array.Length);
            Span <Int16> span = new Span <Int16>(array);

            WaveletTransformation.CDF53MultiLevel(span);

            Span <Int16> transformed = stackalloc Int16[array.Length];

            span.CopyTo(transformed);

            WaveletTransformation.CDF53InverseMultiLevel(span);

            AssertEqualityAndDumpInt(array, copy, transformed);
        }
示例#4
0
        public void TestCDF53ReversibilitySByte()
        {
            SByte[] array = new SByte[2048];
            for (int i = 0; i < array.Length; i++)
            {
                array[i] = (SByte)(SByte.MaxValue * Math.Sin(2.0 * Math.PI * i / array.Length));
            }
            SByte[] copy = new SByte[array.Length];
            Array.Copy(array, copy, array.Length);
            Span <SByte> span = new Span <SByte>(array);

            WaveletTransformation.CDF53MultiLevel(span);

            Span <SByte> transformed = stackalloc SByte[array.Length];

            span.CopyTo(transformed);

            WaveletTransformation.CDF53InverseMultiLevel(span);

            AssertEqualityAndDumpInt(array, copy, transformed);
        }
示例#5
0
        public void TestHaarReversiblityInt()
        {
            int[] array = new int[2048];
            for (int i = 0; i < array.Length; i++)
            {
                array[i] = (int)(int.MaxValue * Math.Sin(2.0 * Math.PI * i / array.Length));
            }
            int[] copy = new int[array.Length];
            Array.Copy(array, copy, array.Length);

            Span <int> span = new Span <int>(array);

            WaveletTransformation.HaarMultiLevel(span);

            Span <int> transformed = stackalloc int[array.Length];

            span.CopyTo(transformed);

            WaveletTransformation.HaarInverseMultiLevel(span);
            AssertEqualityAndDumpInt(array, copy, transformed);
        }