public void ProcessSignalAtCutOffFrequencyTestTest() { const double fd = 100; const double dt = 1 / fd; const double f0 = 10; const double eps = 3.02e-4; const double A0 = Consts.sqrt_2; var x0 = new SamplesDigitalSignal(dt, 1024, t => A0 * Cos(2 * PI * f0 * t)); var x0_power = x0.Power; Assert.AreEqual(1, x0_power, eps); var rc = new HighPassRC(f0, dt); var y0 = rc.Process(x0); var y0_power = y0.Power; Assert.AreEqual(x0_power / 2, y0_power, eps); }
public void ImpulseResponseTest() { const double fd = 100; const double dt = 1 / fd; const double f0 = 10; var rc = new HighPassRC(f0, dt); var a = rc.A; var b = rc.B; var a0 = a[0]; var a1 = a[1] / a0; var b0 = b[0] / a0; var b1 = b[1] / a0; var expected_impulse_response = new List <double> { b0, b0 * -a1 + b1, b0 * -a1 * -a1 + b1 * -a1, b0 * -a1 * -a1 * -a1 + b1 * -a1 * -a1, b0 * -a1 * -a1 * -a1 * -a1 + b1 * -a1 * -a1 * -a1, b0 * -a1 * -a1 * -a1 * -a1 * -a1 + b1 * -a1 * -a1 * -a1 * -a1, }; var delta = new double[expected_impulse_response.Count]; delta[0] = 1; var impulse_response = rc.Process(delta).ToArray(); const double eps = 1.11023e-16; CollectionAssert.AreEqual(expected_impulse_response, impulse_response, GetComparer(eps)); }