com.opengamma.strata.math.impl.interpolation.SineWeightingFunction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of strata-math Show documentation
Show all versions of strata-math Show documentation
Mathematic support for Strata
/*
* Copyright (C) 2012 - present by OpenGamma Inc. and the OpenGamma group of companies
*
* Please see distribution for license.
*/
package com.opengamma.strata.math.impl.interpolation;
import com.opengamma.strata.collect.ArgChecker;
/**
* Weighting function based on {@code Math.sin}.
*/
final class SineWeightingFunction
implements WeightingFunction {
static final SineWeightingFunction INSTANCE = new SineWeightingFunction();
private SineWeightingFunction() {
}
@Override
public double getWeight(double y) {
ArgChecker.inRangeInclusive(y, 0d, 1d, "y");
return 0.5 * (Math.sin(Math.PI * (y - 0.5)) + 1);
}
@Override
public String getName() {
return "Sine";
}
//-------------------------------------------------------------------------
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (this == obj) {
return true;
}
if (getClass() != obj.getClass()) {
return false;
}
return true;
}
@Override
public int hashCode() {
return toString().hashCode();
}
@Override
public String toString() {
return "Sine weighting function";
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy