Package it.unimi.dsi.fastutil.doubles

Examples of it.unimi.dsi.fastutil.doubles.DoubleList


        } else {
            chans = Collections.emptyMap();
            typedChans = Collections.emptyMap();
        }
        LongList builtIds;
        DoubleList builtScores;
        if (reuse) {
            ids.trim();
            builtIds = ids;
            scores.trim();
            builtScores = scores;
View Full Code Here


            }
        }

        @Override
        public double getUnboxedChannelValue(Symbol sym) {
            DoubleList array = unboxedChannels.get(sym);
            if (array != null) {
                return array.get(index);
            } else {
                throw new NullPointerException("no symbol " + sym);
            }
        }
View Full Code Here

    }

    @Test
    public void testAddMany() {
        Random rng = new Random();
        DoubleList vals = new DoubleArrayList(25);
        for (int i = 0; i < 25; i++) {
            double v = rng.nextGaussian() + Math.PI;
            builder.add(i, v);
            vals.add(v);
        }
        assertThat(builder.size(), equalTo(25));
        PackedScoredIdList list = builder.build();
        assertThat(list, hasSize(25));
        for (int i = 0; i < 25; i++) {
            ScoredId id = new ScoredIdBuilder(i, vals.getDouble(i)).build();
            assertThat(list.get(i), equalTo(id));
        }
    }
View Full Code Here

  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));
  }
View Full Code Here

    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 Pair.of(fullStrikes, fullValues);
  }
View Full Code Here

      final int minNumberOfStrikes) {
    final int nExpiries = expiries.length;
    final int nStrikes = strikes.length;
    final List<double[]> fullStrikes = new ArrayList<>();
    final List<double[]> fullValues = new ArrayList<>();
    final DoubleList availableExpiries = new DoubleArrayList();
    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]);
      } else if (availableVols.size() >= minNumberOfStrikes) {
        availableExpiries.add(expiries[i]);
        fullStrikes.add(availableStrikes.toDoubleArray());
        fullValues.add(availableVols.toDoubleArray());
      }
    }
    return new Triple<>(availableExpiries.toDoubleArray(), fullStrikes.toArray(new double[0][]), fullValues.toArray(new double[0][]));
  }
View Full Code Here

    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 new Triple<>(getArrayOfDoubles(expiries), strikes, values);
  }
View Full Code Here

  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));
  }
View Full Code Here

TOP

Related Classes of it.unimi.dsi.fastutil.doubles.DoubleList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.