001package kernels; 002 003import org.junit.Test; 004import static org.junit.Assert.*; 005 006 007/** 008 * Unit tests for the class {@link kernels.OneParticleKernel}. 009 */ 010public class OneParticleKernelTest { 011 012 /** 013 * Tests finding the spectrum of a kernel 014 * using a kernel approximation of the identity operator. 015 */ 016 @Test 017 public void testFindSpectrum() { 018 019 final double r = 20.0; 020 final int n = 10; 021 final double step = 2*r/n; 022 023 OneParticleKernel unity = new OneParticleKernel() { 024 public double kernelValue(double theta, double eta) { 025 if (Math.abs(theta-eta) < step/2) { 026 return 1.0/step; 027 } else { 028 return 0.0; 029 } 030 } 031 }; 032 unity.disableEVCheck(); 033 034 double[] actual = unity.findSpectrum(n, r); 035 double[] expected = new double[] {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; 036 assertArrayEquals("testing spectrum of identity", expected, actual, 1e-10); 037 038 } 039 040 041}