Exemplo n.º 1
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;
            }
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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);
        }