本文整理汇总了Java中it.unimi.dsi.fastutil.doubles.DoubleArrayList类的典型用法代码示例。如果您正苦于以下问题:Java DoubleArrayList类的具体用法?Java DoubleArrayList怎么用?Java DoubleArrayList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DoubleArrayList类属于it.unimi.dsi.fastutil.doubles包,在下文中一共展示了DoubleArrayList类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: ensureScalarVar
import it.unimi.dsi.fastutil.doubles.DoubleArrayList; //导入依赖的package包/类
final public void ensureScalarVar(String name, int size, double initial, boolean randomize) {
writeLock.lock();
try {
int curSize = scalarVars.get(name).size();
if (curSize < size) {
DoubleList toAdd = new DoubleArrayList(size - curSize);
for (int i=0; i<size - curSize; i++) {
toAdd.add(0.0);
}
initializeDoubleList(toAdd, initial, randomize);
scalarVars.get(name).addAll(toAdd);
}
curSize = readLocks.size();
SpaceUtilities.fillReadWriteLocks(readLocks, writeLocks, curSize, size);
} finally {
writeLock.unlock();
}
}
开发者ID:grouplens,项目名称:samantha,代码行数:19,代码来源:SynchronizedVariableSpace.java
示例2: featurize
import it.unimi.dsi.fastutil.doubles.DoubleArrayList; //导入依赖的package包/类
public LearningInstance featurize(JsonNode entity, boolean update) {
Map<String, List<Feature>> feaMap = FeaturizerUtilities.getFeatureMap(entity, true,
featureExtractors, indexSpace);
String group = null;
if (groupKeys != null && groupKeys.size() > 0) {
group = FeatureExtractorUtilities.composeConcatenatedKey(entity, groupKeys);
}
TensorFlowInstance instance = new TensorFlowInstance(group);
for (Map.Entry<String, List<Feature>> entry : feaMap.entrySet()) {
DoubleList doubles = new DoubleArrayList();
IntList ints = new IntArrayList();
for (Feature feature : entry.getValue()) {
doubles.add(feature.getValue());
ints.add(feature.getIndex());
}
double[] darr = doubles.toDoubleArray();
instance.putValues(entry.getKey(), darr);
int[] iarr = ints.toIntArray();
instance.putIndices(entry.getKey(), iarr);
}
return instance;
}
开发者ID:grouplens,项目名称:samantha,代码行数:23,代码来源:TensorFlowModel.java
示例3: getSurfaceFromVolatilityQuote
import it.unimi.dsi.fastutil.doubles.DoubleArrayList; //导入依赖的package包/类
private static VolatilitySurfaceData<Double, Double> getSurfaceFromVolatilityQuote(final VolatilitySurfaceData<Number, Double> optionVolatilities, final ZonedDateTime now,
final Calendar calendar) {
final BondFutureOptionExpiryCalculator expiryCalculator = BondFutureOptionExpiryCalculator.getInstance();
final Map<Pair<Double, Double>, Double> volatilityValues = new HashMap<Pair<Double, Double>, Double>();
final DoubleArrayList tList = new DoubleArrayList();
final DoubleArrayList kList = new DoubleArrayList();
final LocalDate today = now.toLocalDate();
final Object[] xs = optionVolatilities.getXs();
for (final Object xObj : xs) {
Number x = (Number) xObj;
final Double t = TimeCalculator.getTimeBetween(today, expiryCalculator.getExpiryDate(x.intValue(), today, calendar));
final Object[] ys = optionVolatilities.getYs();
for (final Object yObj : ys) {
Double y = (Double) yObj;
final Double volatility = optionVolatilities.getVolatility(x, y);
if (volatility != null) {
tList.add(t);
kList.add(y / 100.);
volatilityValues.put(Pairs.of(t, y / 100.), volatility / 100); // TODO Normalisation, could this be done elsewhere?
}
}
}
return new VolatilitySurfaceData<Double, Double>(optionVolatilities.getDefinitionName(), optionVolatilities.getSpecificationName(), optionVolatilities.getTarget(),
tList.toArray(new Double[0]), kList.toArray(new Double[0]), volatilityValues);
}
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:26,代码来源:BondFutureOptionVolatilitySurfaceDataFunction.java
示例4: getSurface
import it.unimi.dsi.fastutil.doubles.DoubleArrayList; //导入依赖的package包/类
private static VolatilitySurfaceData<Double, Double> getSurface(final VolatilitySurfaceData<Tenor, Tenor> volatilities) {
final Map<Pair<Double, Double>, Double> volatilityValues = new HashMap<Pair<Double, Double>, Double>();
final DoubleArrayList xList = new DoubleArrayList();
final DoubleArrayList yList = new DoubleArrayList();
for (final Tenor x : volatilities.getUniqueXValues()) {
final double xTime = getTime(x);
final List<ObjectsPair<Tenor, Double>> yValuesForX = volatilities.getYValuesForX(x);
for (final ObjectsPair<Tenor, Double> pair : yValuesForX) {
final double yTime = getTime(pair.getFirst());
final Double volatility = pair.getSecond();
if (volatility != null) {
xList.add(xTime);
yList.add(yTime);
volatilityValues.put(DoublesPair.of(xTime, yTime), volatility);
}
}
}
return new VolatilitySurfaceData<Double, Double>(volatilities.getDefinitionName(), volatilities.getSpecificationName(), volatilities.getTarget(), xList.toArray(new Double[0]),
yList.toArray(new Double[0]), volatilityValues);
}
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:21,代码来源:SwaptionATMVolatilitySurfaceDataFunction.java
示例5: getSurfaceFromVolatilityQuote
import it.unimi.dsi.fastutil.doubles.DoubleArrayList; //导入依赖的package包/类
/** Build a volatility surface based on Expiry, T, and Strike, K. T is in measured in our standard OG-Analytic years */
private static VolatilitySurfaceData<Double, Double> getSurfaceFromVolatilityQuote(final VolatilitySurfaceData<Object, Object> optionVolatilities, final ZonedDateTime now,
final Calendar calendar) {
final Map<Pair<Double, Double>, Double> volatilityValues = new HashMap<>();
final DoubleArrayList tList = new DoubleArrayList();
final DoubleArrayList kList = new DoubleArrayList();
final LocalDate today = now.toLocalDate();
final Object[] xs = optionVolatilities.getXs();
for (final Object xObj : optionVolatilities.getXs()) {
final Number x = (Number) xObj;
final Double t = FutureOptionUtils.getIRFutureOptionTtm(x.intValue(), today, calendar);
final Object[] ys = optionVolatilities.getYs();
for (final Object yObj : ys) {
final Double y = (Double) yObj;
final Double volatility = optionVolatilities.getVolatility(x, y);
if (volatility != null) {
tList.add(t);
kList.add(y / 100.);
volatilityValues.put(Pairs.of(t, y / 100.), volatility / 100); // TODO Normalisation, could this be done elsewhere?
}
}
}
return new VolatilitySurfaceData<>(optionVolatilities.getDefinitionName(), optionVolatilities.getSpecificationName(), optionVolatilities.getTarget(), tList.toArray(new Double[0]),
kList.toArray(new Double[0]), volatilityValues);
}
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:26,代码来源:IRFutureOptionVolatilitySurfaceDataFunction.java
示例6: getSurfaceFromVolatilityQuote
import it.unimi.dsi.fastutil.doubles.DoubleArrayList; //导入依赖的package包/类
private static VolatilitySurfaceData<Double, Double> getSurfaceFromVolatilityQuote(final LocalDate valDate, final VolatilitySurfaceData<Pair<Integer, Tenor>, Double> rawSurface) {
// Remove empties, convert expiries from number to years, and scale vols
final Map<Pair<Double, Double>, Double> volValues = new HashMap<>();
final DoubleArrayList tList = new DoubleArrayList();
final DoubleArrayList kList = new DoubleArrayList();
for (final Pair<Integer, Tenor> nthExpiry : rawSurface.getXs()) {
final double t = FutureOptionExpiries.EQUITY_FUTURE.getFutureOptionTtm(nthExpiry.getFirst(), valDate, nthExpiry.getSecond()); //TODO need information about expiry calculator
if (t > 5. / 365.) { // Bootstrapping vol surface to this data causes far more trouble than any gain. The data simply isn't reliable.
for (final Double strike : rawSurface.getYs()) {
final Double vol = rawSurface.getVolatility(nthExpiry, strike);
if (vol != null) {
tList.add(t);
kList.add(strike);
volValues.put(Pairs.of(t, strike), vol / 100.);
}
}
}
}
final VolatilitySurfaceData<Double, Double> stdVolSurface = new VolatilitySurfaceData<>(rawSurface.getDefinitionName(), rawSurface.getSpecificationName(), rawSurface.getTarget(),
tList.toArray(new Double[0]), kList.toArray(new Double[0]), volValues);
return stdVolSurface;
}
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:23,代码来源:EquityFutureOptionVolatilitySurfaceDataFunction.java
示例7: getStrikesAndValues
import it.unimi.dsi.fastutil.doubles.DoubleArrayList; //导入依赖的package包/类
public static Pair<double[][], double[][]> getStrikesAndValues(final double[] expiries, final double[] strikes, final VolatilitySurfaceData<Object, Object> volatilitySurface) {
final int nExpiries = expiries.length;
final int nStrikes = strikes.length;
final double[][] fullStrikes = new double[nExpiries][];
final double[][] fullValues = new double[nExpiries][];
for (int i = 0; i < nExpiries; i++) {
final DoubleList availableStrikes = new DoubleArrayList();
final DoubleList availableVols = new DoubleArrayList();
for (int j = 0; j < nStrikes; j++) {
final Double vol = volatilitySurface.getVolatility(expiries[i], strikes[j]);
if (vol != null) {
availableStrikes.add(strikes[j]);
availableVols.add(vol);
}
}
if (availableVols.size() == 0) {
throw new OpenGammaRuntimeException("No volatility values found for expiry " + expiries[i]);
}
fullStrikes[i] = availableStrikes.toDoubleArray();
fullValues[i] = availableVols.toDoubleArray();
}
return Pairs.of(fullStrikes, fullValues);
}
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:24,代码来源:BlackVolatilitySurfaceUtils.java
示例8: getStrippedStrikesAndValues
import it.unimi.dsi.fastutil.doubles.DoubleArrayList; //导入依赖的package包/类
public static Triple<double[], double[][], double[][]> getStrippedStrikesAndValues(final VolatilitySurfaceData<Object, Object> volatilitySurface) {
final Object[] expiries = getUniqueExpiriesWithData(volatilitySurface);
final Object[] strikeValues = volatilitySurface.getYs();
final int nExpiries = expiries.length;
final int nStrikes = strikeValues.length;
final double[][] strikes = new double[nExpiries][];
final double[][] values = new double[nExpiries][];
for (int i = 0; i < nExpiries; i++) {
final DoubleList availableStrikes = new DoubleArrayList();
final DoubleList availableVols = new DoubleArrayList();
for (int j = 0; j < nStrikes; j++) {
final Double vol = volatilitySurface.getVolatility(expiries[i], strikeValues[j]);
if (vol != null) {
availableStrikes.add((Double) strikeValues[j]);
availableVols.add(vol);
}
}
strikes[i] = availableStrikes.toDoubleArray();
values[i] = availableVols.toDoubleArray();
}
return Triple.of(getArrayOfDoubles(expiries), strikes, values);
}
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:23,代码来源:BlackVolatilitySurfaceUtils.java
示例9: getResultsForExternalRiskFactors
import it.unimi.dsi.fastutil.doubles.DoubleArrayList; //导入依赖的package包/类
private Set<ComputedValue> getResultsForExternalRiskFactors(final SecuritySource secSource, final FunctionInputs inputs, final ComputationTarget target, final RawSecurity security) {
final List<FactorExposureData> factors = decodeSensitivities(secSource, security);
Collections.sort(factors, new FactorExposureDataComparator());
final List<String> indices = Lists.newArrayList();
final List<String> labels = Lists.newArrayList();
final DoubleList values = new DoubleArrayList();
for (final FactorExposureData factor : factors) {
if (!(factor.getFactorType().equals(FactorType.YIELD) && factor.getFactorName().contains(SWAP_TEXT))) {
final ComputedValue computedValue = inputs.getComputedValue(getSensitivityRequirement(factor.getExposureExternalId()));
if (computedValue != null) {
indices.add(factor.getFactorExternalId().getValue());
labels.add(factor.getExposureExternalId().getValue());
values.add((Double) computedValue.getValue());
} else {
s_logger.error("Value was null when getting required input data " + factor.getExposureExternalId());
}
}
}
final StringLabelledMatrix1D labelledMatrix = new StringLabelledMatrix1D(indices.toArray(new String[] {}), labels.toArray(), values.toDoubleArray());
final ValueSpecification valueSpecification = new ValueSpecification(EXTERNAL_SENSITIVITIES_REQUIREMENT, target.toSpecification(), createCurrencyValueProperties(target).get());
return Collections.singleton(new ComputedValue(valueSpecification, labelledMatrix));
}
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:23,代码来源:ExternallyProvidedSensitivitiesNonYieldCurveFunction.java
示例10: getResultsForExternalRiskFactors
import it.unimi.dsi.fastutil.doubles.DoubleArrayList; //导入依赖的package包/类
private Set<ComputedValue> getResultsForExternalRiskFactors(final SecuritySource secSource, final FunctionInputs inputs, final ComputationTarget target, final RawSecurity security) {
final List<FactorExposureData> factors = decodeSensitivities(secSource, security);
Collections.sort(factors, new FactorExposureDataComparator());
final List<String> indices = Lists.newArrayList();
final List<String> labels = Lists.newArrayList();
final DoubleList values = new DoubleArrayList();
for (final FactorExposureData factor : factors) {
if (factor.getFactorType().equals(FactorType.CDS_SPREAD)) {
final ComputedValue computedValue = inputs.getComputedValue(getSensitivityRequirement(factor.getExposureExternalId()));
if (computedValue != null) {
indices.add(factor.getFactorExternalId().getValue());
labels.add(factor.getExposureExternalId().getValue());
values.add((Double) computedValue.getValue());
} else {
s_logger.error("Value was null when getting required input data " + factor.getExposureExternalId());
}
}
}
final StringLabelledMatrix1D labelledMatrix = new StringLabelledMatrix1D(indices.toArray(new String[] {}), labels.toArray(), values.toDoubleArray());
final ValueSpecification valueSpecification = new ValueSpecification(CREDIT_SENSITIVITIES_REQUIREMENT, target.toSpecification(), createCurrencyValueProperties(target).get());
return Collections.singleton(new ComputedValue(valueSpecification, labelledMatrix));
}
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:23,代码来源:ExternallyProvidedSensitivitiesCreditFactorsFunction.java
示例11: getGenerator
import it.unimi.dsi.fastutil.doubles.DoubleArrayList; //导入依赖的package包/类
@Override
protected GeneratorYDCurve getGenerator(final CurveDefinition definition, final LocalDate valuationDate) {
if (definition instanceof InterpolatedCurveDefinition) {
final InterpolatedCurveDefinition interpolatedDefinition = (InterpolatedCurveDefinition) definition;
final String interpolatorName = interpolatedDefinition.getInterpolatorName();
final String leftExtrapolatorName = interpolatedDefinition.getLeftExtrapolatorName();
final String rightExtrapolatorName = interpolatedDefinition.getRightExtrapolatorName();
final Interpolator1D interpolator = CombinedInterpolatorExtrapolatorFactory.getInterpolator(interpolatorName, leftExtrapolatorName, rightExtrapolatorName);
if (definition instanceof FixedDateInterpolatedCurveDefinition) {
final FixedDateInterpolatedCurveDefinition fixedDateDefinition = (FixedDateInterpolatedCurveDefinition) definition;
final List<LocalDate> fixedDates = fixedDateDefinition.getFixedDates();
final DoubleArrayList nodePoints = new DoubleArrayList(fixedDates.size()); //TODO what about equal node points?
for (final LocalDate fixedDate : fixedDates) {
nodePoints.add(TimeCalculator.getTimeBetween(valuationDate, fixedDate)); //TODO what to do if the fixed date is before the valuation date?
}
final double anchor = nodePoints.get(0); //TODO should the anchor go into the definition?
return new GeneratorCurveYieldInterpolatedAnchorNode(nodePoints.toDoubleArray(), anchor, interpolator);
}
return new GeneratorCurveYieldInterpolated(getMaturityCalculator(), interpolator);
}
throw new OpenGammaRuntimeException("Cannot handle curves of type " + definition.getClass());
}
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:23,代码来源:MultiCurveDiscountingFunction.java
示例12: getFXForwardCurve
import it.unimi.dsi.fastutil.doubles.DoubleArrayList; //导入依赖的package包/类
protected static DoublesCurve getFXForwardCurve(final FunctionInputs inputs, final FXForwardCurveDefinition definition, final FXForwardCurveSpecification specification, final LocalDate now) {
final Object fxForwardCurveObject = inputs.getValue(ValueRequirementNames.FX_FORWARD_POINTS_CURVE_MARKET_DATA);
if (fxForwardCurveObject == null) {
throw new OpenGammaRuntimeException("Could not get FX forward curve data");
}
@SuppressWarnings("unchecked")
final Map<ExternalId, Double> dataPoints = (Map<ExternalId, Double>) fxForwardCurveObject;
final DoubleArrayList tList = new DoubleArrayList();
final DoubleArrayList fxList = new DoubleArrayList();
for (final Tenor tenor : definition.getTenors()) {
final Double fxForward = dataPoints.get(specification.getCurveInstrumentProvider().getInstrument(now, tenor));
if (fxForward == null) {
throw new OpenGammaRuntimeException("Could not get FX forward rate for " + tenor);
}
tList.add(DateUtils.getDifferenceInYears(now, now.plus(tenor.getPeriod())));
fxList.add(fxForward);
}
final Interpolator1D interpolator = CombinedInterpolatorExtrapolatorFactory.getInterpolator(Interpolator1DFactory.LINEAR, Interpolator1DFactory.LINEAR_EXTRAPOLATOR,
Interpolator1DFactory.LINEAR_EXTRAPOLATOR);
return InterpolatedDoublesCurve.from(tList.toDoubleArray(), fxList.toDoubleArray(), interpolator);
}
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:22,代码来源:FXForwardPointsMethodFunction.java
示例13: getResult
import it.unimi.dsi.fastutil.doubles.DoubleArrayList; //导入依赖的package包/类
@Override
public Interpolator1DDataBundle getResult(final LocalVolatilitySurfaceMoneyness localVolatility, final ForwardCurve forwardCurve, final EuropeanVanillaOption option,
final YieldAndDiscountCurve discountingCurve) {
final PDETerminalResults1D pdeGrid = _pdeCalculator.runPDESolver(localVolatility, option);
final PDEGrid1D grid = pdeGrid.getGrid();
final double expiry = option.getTimeToExpiry();
final boolean isCall = option.isCall();
final double strike = option.getStrike();
final double forward = forwardCurve.getForward(expiry);
final double[] moneynesses = grid.getSpaceNodes();
final double[] modifiedPrices = pdeGrid.getTerminalResults();
final int n = modifiedPrices.length;
final DoubleArrayList strikes = new DoubleArrayList();
final DoubleArrayList prices = new DoubleArrayList();
for (int i = 0; i < n; i++) {
try {
final double impliedVol = BlackFormulaRepository.impliedVolatility(modifiedPrices[i], 1, moneynesses[i], expiry, isCall);
prices.add(BlackFormulaRepository.price(forward, strike, expiry, impliedVol, isCall));
strikes.add(forward * moneynesses[i]);
} catch (final Exception e) {
}
}
return _interpolator.getDataBundleFromSortedArrays(strikes.toDoubleArray(), prices.toDoubleArray());
}
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:25,代码来源:LocalVolatilityForwardPDEPriceGridCalculator.java
示例14: G2ppPiecewiseConstantParameters
import it.unimi.dsi.fastutil.doubles.DoubleArrayList; //导入依赖的package包/类
/**
* Constructor from the model parameters.
* @param meanReversion The mean reversion speed (2) parameters.
* @param volatility The volatility parameters. There are two volatility list, one for each factor.
* @param volatilityTime The times separating the constant volatility periods.
* @param correlation The model correlation.
*/
public G2ppPiecewiseConstantParameters(final double[] meanReversion, final double[][] volatility, final double[] volatilityTime, final double correlation) {
ArgumentChecker.notNull(meanReversion, "mean reversion");
ArgumentChecker.notNull(volatility, "volatility");
ArgumentChecker.notNull(volatilityTime, "volatility time");
ArgumentChecker.isTrue(meanReversion.length == 2, "Two mean reversions required");
ArgumentChecker.isTrue(volatility.length == 2, "Two volatility arrays required");
ArgumentChecker.isTrue(volatility[0].length == volatility[1].length, "Volatility length");
ArgumentChecker.isTrue(volatility[0].length == volatilityTime.length + 1, "Number of times incorrect; had {}, need {}", volatilityTime.length + 1, volatility[0].length);
_meanReversion = meanReversion;
_volatility[0] = new DoubleArrayList(volatility[0]);
_volatility[1] = new DoubleArrayList(volatility[1]);
final double[] volatilityTimeArray = new double[volatilityTime.length + 2];
volatilityTimeArray[0] = 0.0;
volatilityTimeArray[volatilityTime.length + 1] = VOLATILITY_TIME_INFINITY;
System.arraycopy(volatilityTime, 0, volatilityTimeArray, 1, volatilityTime.length);
_volatilityTime = new DoubleArrayList(volatilityTimeArray);
// TODO: check that the time are increasing.
_correlation = correlation;
}
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:27,代码来源:G2ppPiecewiseConstantParameters.java
示例15: evaluate
import it.unimi.dsi.fastutil.doubles.DoubleArrayList; //导入依赖的package包/类
@Override
public VaRCalculationResult evaluate(final EmpiricalDistributionVaRParameters parameters, final DoubleTimeSeries<?>... data) {
ArgumentChecker.notNull(parameters, "parameters");
ArgumentChecker.notNull(data, "data");
final double var = _varCalculator.evaluate(parameters, data).getVaRValue();
final DoubleArrayList excesses = new DoubleArrayList();
for (final double portfolioReturn : data[0].valuesArrayFast()) {
if (portfolioReturn < -var) {
excesses.add(portfolioReturn);
}
}
if (excesses.isEmpty()) {
return new VaRCalculationResult(var, null);
}
return new VaRCalculationResult(-_meanCalculator.evaluate(excesses.toDoubleArray()), null);
}
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:17,代码来源:EmpiricalDistributionConditionalVaRCalculator.java
示例16: reduceCurveNodes
import it.unimi.dsi.fastutil.doubles.DoubleArrayList; //导入依赖的package包/类
/**
* Matrix reducing the nodes, to which portfolio has sensitivities, to new nodes (objNodes), for which sensitivity is accounted for, when relevant curves are already known
* @param curves The relevant curves
* @param objNodes The objective nodes on which sensitivity is to be accounted for
* @return The matrix
*/
public DoubleMatrix2D reduceCurveNodes(final YieldAndDiscountCurve[] curves, final double[] objNodes) {
ArgumentChecker.notNull(curves, "curves");
ArgumentChecker.notNull(objNodes, "objNodes");
int nCurves = curves.length;
DoubleArrayList result = new DoubleArrayList();
for (int i = 0; i < nCurves; ++i) {
Double[] nodes = getNodes(curves[i]);
for (final double element : nodes) {
result.add(element);
}
}
int totalNum = result.size();
int[] tmp = toPositions(objNodes, result.toDoubleArray());
int objNum = tmp.length;
double[][] res = new double[objNum][totalNum];
for (int i = 0; i < objNum; ++i) {
Arrays.fill(res[i], 0.0);
res[i][tmp[i]] = 1.0;
}
return new DoubleMatrix2D(res);
}
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:32,代码来源:ParameterSensitivityWeightMatrixCalculator.java
示例17: getGenerator
import it.unimi.dsi.fastutil.doubles.DoubleArrayList; //导入依赖的package包/类
private GeneratorYDCurve getGenerator(final AbstractCurveDefinition definition, LocalDate valuationDate) {
if (definition instanceof InterpolatedCurveDefinition) {
final InterpolatedCurveDefinition interpolatedDefinition = (InterpolatedCurveDefinition) definition;
final String interpolatorName = interpolatedDefinition.getInterpolatorName();
final String leftExtrapolatorName = interpolatedDefinition.getLeftExtrapolatorName();
final String rightExtrapolatorName = interpolatedDefinition.getRightExtrapolatorName();
final Interpolator1D interpolator = CombinedInterpolatorExtrapolatorFactory.getInterpolator(interpolatorName,
leftExtrapolatorName,
rightExtrapolatorName);
if (definition instanceof FixedDateInterpolatedCurveDefinition) {
final FixedDateInterpolatedCurveDefinition fixedDateDefinition = (FixedDateInterpolatedCurveDefinition) definition;
final List<LocalDate> fixedDates = fixedDateDefinition.getFixedDates();
final DoubleArrayList nodePoints = new DoubleArrayList(fixedDates.size()); //TODO what about equal node points?
for (final LocalDate fixedDate : fixedDates) {
nodePoints.add(TimeCalculator.getTimeBetween(valuationDate, fixedDate)); //TODO what to do if the fixed date is before the valuation date?
}
final double anchor = nodePoints.get(0); //TODO should the anchor go into the definition?
return new GeneratorCurveYieldInterpolatedAnchorNode(nodePoints.toDoubleArray(), anchor, interpolator);
}
return new GeneratorCurveYieldInterpolated(LastTimeCalculator.getInstance(), interpolator);
}
throw new OpenGammaRuntimeException("Cannot handle curves of type " + definition.getClass());
}
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:26,代码来源:DefaultDiscountingMulticurveBundleFn.java
示例18: getGenerator
import it.unimi.dsi.fastutil.doubles.DoubleArrayList; //导入依赖的package包/类
private GeneratorYDCurve getGenerator(final AbstractCurveDefinition definition, LocalDate valuationDate) {
if (definition instanceof InterpolatedCurveDefinition) {
InterpolatedCurveDefinition interpolatedDefinition = (InterpolatedCurveDefinition) definition;
String interpolatorName = interpolatedDefinition.getInterpolatorName();
String leftExtrapolatorName = interpolatedDefinition.getLeftExtrapolatorName();
String rightExtrapolatorName = interpolatedDefinition.getRightExtrapolatorName();
Interpolator1D interpolator = CombinedInterpolatorExtrapolatorFactory.getInterpolator(interpolatorName,
leftExtrapolatorName,
rightExtrapolatorName);
if (definition instanceof FixedDateInterpolatedCurveDefinition) {
FixedDateInterpolatedCurveDefinition fixedDateDefinition = (FixedDateInterpolatedCurveDefinition) definition;
List<LocalDate> fixedDates = fixedDateDefinition.getFixedDates();
DoubleArrayList nodePoints = new DoubleArrayList(fixedDates.size()); //TODO what about equal node points?
for (final LocalDate fixedDate : fixedDates) {
//TODO what to do if the fixed date is before the valuation date?
nodePoints.add(TimeCalculator.getTimeBetween(valuationDate, fixedDate));
}
final double anchor = nodePoints.get(0); //TODO should the anchor go into the definition?
return new GeneratorCurveYieldInterpolatedAnchorNode(nodePoints.toDoubleArray(), anchor, interpolator);
}
return new GeneratorCurveYieldInterpolated(LastTimeCalculator.getInstance(), interpolator);
}
throw new OpenGammaRuntimeException("Cannot handle curves of type " + definition.getClass());
}
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:27,代码来源:CurveBundleProviderFn.java
示例19: createCurveGenerator
import it.unimi.dsi.fastutil.doubles.DoubleArrayList; //导入依赖的package包/类
/**
* Creates a curve generator for a curve definition and valuation date.
*
* @param definition the curve definition
* @param valuationDate the valuation date
* @return a generator capable of generating the curve
*/
private GeneratorYDCurve createCurveGenerator(AbstractCurveDefinition definition, LocalDate valuationDate) {
if (definition instanceof InterpolatedCurveDefinition) {
InterpolatedCurveDefinition interpolatedDefinition = (InterpolatedCurveDefinition) definition;
Interpolator1D interpolator =
CombinedInterpolatorExtrapolatorFactory.getInterpolator(interpolatedDefinition.getInterpolatorName(),
interpolatedDefinition.getLeftExtrapolatorName(),
interpolatedDefinition.getRightExtrapolatorName());
if (definition instanceof FixedDateInterpolatedCurveDefinition) {
FixedDateInterpolatedCurveDefinition fixedDateDefinition = (FixedDateInterpolatedCurveDefinition) definition;
List<LocalDate> fixedDates = fixedDateDefinition.getFixedDates();
DoubleArrayList nodePoints = new DoubleArrayList(fixedDates.size()); //TODO what about equal node points?
for (LocalDate fixedDate : fixedDates) {
nodePoints.add(TimeCalculator.getTimeBetween(valuationDate, fixedDate)); //TODO what to do if the fixed date is before the valuation date?
}
double anchor = nodePoints.get(0); //TODO should the anchor go into the definition?
return new GeneratorCurveYieldInterpolatedAnchorNode(nodePoints.toDoubleArray(), anchor, interpolator);
}
return new GeneratorCurveYieldInterpolated(LastTimeCalculator.getInstance(), interpolator);
}
throw new OpenGammaRuntimeException("Cannot handle curves of type " + definition.getClass());
}
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:30,代码来源:AbstractMulticurveMarketDataBuilder.java
示例20: CachedNeighborhood
import it.unimi.dsi.fastutil.doubles.DoubleArrayList; //导入依赖的package包/类
/**
* Constructor that calculates and caches neighborhoods.
*
* @param n number of users/items
* @param neighborhood generic neighborhood to be cached
*/
public CachedNeighborhood(int n, Neighborhood neighborhood) {
this.idxla = new IntArrayList[n];
this.simla = new DoubleArrayList[n];
range(0, n).parallel().forEach(idx -> {
IntArrayList idxl = new IntArrayList();
DoubleArrayList siml = new DoubleArrayList();
neighborhood.getNeighbors(idx).forEach(is -> {
idxl.add(is.v1);
siml.add(is.v2);
});
idxla[idx] = idxl;
simla[idx] = siml;
});
}
开发者ID:RankSys,项目名称:RankSys,代码行数:23,代码来源:CachedNeighborhood.java
注:本文中的it.unimi.dsi.fastutil.doubles.DoubleArrayList类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论