/* * Karinto Library Project * * This software is distributed under a zlib-style license. * See license.txt for more information. */ using System; using System.Collections.Generic; using System.Text; using System.Diagnostics; using Karinto; using Karinto.Numeric; using NUnit.Framework; namespace KarintoTest { [TestFixture] public class FftTest { [Test] public void Test() { Complex[] input = MakeComplexSample(); Complex[] output = Fft.TransformForward(input); } [Test] public void RealToComplex() { double[] input = MakeRealSample(); Fft r2c = new Fft(input.Length, Fft.Direction.Forward); Complex[] output; r2c.Transform(input, out output); } private Complex[] MakeComplexSample() { Complex[] a = new Complex[64]; for (int i = 0; i < 16; ++i) { a[i] = new Complex(i * 0.125, 0); } for (int i = 16; i < 48; ++i) { a[i] = new Complex(4.0 - i * 0.125, 0); } for (int i = 48; i < 64; ++i) { a[i] = new Complex(i * 0.125 - 8.0, 0); } return a; } private double[] MakeRealSample() { double[] a = new double[64]; for (int i = 0; i < 16; ++i) { a[i] = i * 0.125; } for (int i = 16; i < 48; ++i) { a[i] = 4.0 - i * 0.125; } for (int i = 48; i < 64; ++i) { a[i] = i * 0.125 - 8.0; } return a; } } }