DeltaMeanCalculator extends Function1D<Map<Integer, ParametricVaRDataBundle>, Double> { @Override public Double evaluate(final Map<Integer, ParametricVaRDataBundle> data) { Validate.notNull(data, "data"); Validate.isTrue(data.containsKey(1)); final ParametricVaRDataBundle deltaData = data.get(1); final DoubleMatrix1D mean = deltaData.getExpectedReturn(); final DoubleMatrix1D delta = (DoubleMatrix1D) deltaData.getSensitivities(); return _algebra.getInnerProduct(delta, mean); } DeltaMeanCalculator(final MatrixAlgebra algebra); @Override Double evaluate(final Map<Integer, ParametricVaRDataBundle> data); @Override int hashCode(); @Override boolean equals(final Object obj);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullData() { F.evaluate((Map<Integer, ParametricVaRDataBundle>) null); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testEmptyValueDeltaVector() { final ParametricVaRDataBundle data = new ParametricVaRDataBundle(null, null, EMPTY_VECTOR, EMPTY_MATRIX, 1); final Map<Integer, ParametricVaRDataBundle> bundle = Collections.singletonMap(1, data); F.evaluate(bundle); }
@Test public void test() { ParametricVaRDataBundle data = new ParametricVaRDataBundle(null, ZERO, VECTOR, MATRIX, 1); Map<Integer, ParametricVaRDataBundle> bundle = Collections.singletonMap(1, data); assertEquals(F.evaluate(bundle), 0, 1e-9); data = new ParametricVaRDataBundle(null, VECTOR, VECTOR, MATRIX, 1); bundle = Collections.singletonMap(1, data); assertEquals(F.evaluate(bundle), 9, 1e-9); }