FuAlgo { double getTristimulusValue(double[] spectrum, double[] factors) { if (spectrum.length != factors.length) { throw new IllegalArgumentException("The spectrum must have equal length as factors."); } double summation = 0; for (int i = 0; i < spectrum.length; i++) { summation = (spectrum[i] * factors[i]) + summation; } return summation; } FuAlgo(Instrument instrument);   FuAlgo(); FuResult compute(double[] spectrum); static final byte MAX_FU_VALUE; }
@Test public void testGetTristimulusValue() throws Exception { final double[] spectrum = new double[]{0.222, 0.219, 0.277, 0.219, 0.235, 0.260, 0.281, 0.287, 0.273}; assertEquals(26.36134, fuAlgo.getTristimulusValue(spectrum, xFactor), 1e-8); assertEquals(25.691876, fuAlgo.getTristimulusValue(spectrum, yFactor), 1e-8); assertEquals(24.818239000000005, fuAlgo.getTristimulusValue(spectrum, zFactor), 1e-8); }
@Test(expected = IllegalArgumentException.class) public void testCheckNumberOfBands() throws Exception { fuAlgo.getTristimulusValue(new double[4], xFactor); }