final boolean opposite) {
ArgumentChecker.notNull(sensitivity1, "sensitivity1");
ArgumentChecker.notNull(sensitivity2, "sensitivity2");
ArgumentChecker.isTrue(tolerance > 0, "tolerance must be greater than 0; have {}", tolerance);
boolean cmp = true;
final MatrixAlgebra algebra = MatrixAlgebraFactory.COMMONS_ALGEBRA;
final Map<Pair<String, Currency>, DoubleMatrix1D> map1 = sensitivity1.getSensitivities();
final Map<Pair<String, Currency>, DoubleMatrix1D> map2 = sensitivity2.getSensitivities();
for (final Map.Entry<Pair<String, Currency>, DoubleMatrix1D> entry : map1.entrySet()) {
final Pair<String, Currency> nameCcy = entry.getKey();
if (map2.get(nameCcy) == null) {
if (algebra.getNormInfinity(entry.getValue()) > tolerance) {
cmp = false;
}
} else {
if (algebra.getNormInfinity(algebra.add(entry.getValue(), algebra.scale(map2.get(nameCcy), -1.0))) > tolerance) {
cmp = false;
}
}
}
for (final Map.Entry<Pair<String, Currency>, DoubleMatrix1D> entry : map2.entrySet()) {
final Pair<String, Currency> nameCcy = entry.getKey();
if (map1.get(nameCcy) == null) {
if (algebra.getNormInfinity(entry.getValue()) > tolerance) {
cmp = false;
}
} else {
if (algebra.getNormInfinity(algebra.add(entry.getValue(), algebra.scale(map1.get(nameCcy), -1.0))) > tolerance) {
cmp = false;
}
}
}
if (opposite) {