List of usage examples for java.util Arrays binarySearch
public static int binarySearch(Object[] a, Object key)
From source file:CSVFileWriter.java
/** * is ignored characters/*from w w w. j a va 2s .c o m*/ * @param c * @return */ public boolean isIgnored(char c) { return Arrays.binarySearch(ignoreCharacters, c) >= 0; }
From source file:com.opengamma.examples.bloomberg.loader.DemoEquityOptionCollarPortfolioLoader.java
private void addNodes(final ManageablePortfolioNode rootNode, final String underlying, final boolean includeUnderlying, final Period[] expiries) { final ExternalId ticker = ExternalSchemes.bloombergTickerSecurityId(underlying); ManageableSecurity underlyingSecurity = null; if (includeUnderlying) { underlyingSecurity = getOrLoadEquity(ticker); }/*w w w . jav a 2 s. co m*/ final ExternalIdBundle bundle = underlyingSecurity == null ? ExternalIdBundle.of(ticker) : underlyingSecurity.getExternalIdBundle(); final HistoricalTimeSeriesInfoDocument timeSeriesInfo = getOrLoadTimeSeries(ticker, bundle); final double estimatedCurrentStrike = getOrLoadMostRecentPoint(timeSeriesInfo); final Set<ExternalId> optionChain = getOptionChain(ticker); //TODO: reuse positions/nodes? final String longName = underlyingSecurity == null ? "" : underlyingSecurity.getName(); final String formattedName = MessageFormatter.format("[{}] {}", underlying, longName).getMessage(); final ManageablePortfolioNode equityNode = new ManageablePortfolioNode(formattedName); final BigDecimal underlyingAmount = VALUE_OF_UNDERLYING.divide(BigDecimal.valueOf(estimatedCurrentStrike), BigDecimal.ROUND_HALF_EVEN); if (includeUnderlying) { addPosition(equityNode, underlyingAmount, ticker); } final TreeMap<LocalDate, Set<BloombergTickerParserEQOption>> optionsByExpiry = new TreeMap<LocalDate, Set<BloombergTickerParserEQOption>>(); for (final ExternalId optionTicker : optionChain) { s_logger.debug("Got option {}", optionTicker); final BloombergTickerParserEQOption optionInfo = BloombergTickerParserEQOption .getOptionParser(optionTicker); s_logger.debug("Got option info {}", optionInfo); final LocalDate key = optionInfo.getExpiry(); Set<BloombergTickerParserEQOption> set = optionsByExpiry.get(key); if (set == null) { set = new HashSet<BloombergTickerParserEQOption>(); optionsByExpiry.put(key, set); } set.add(optionInfo); } final Set<ExternalId> tickersToLoad = new HashSet<ExternalId>(); final BigDecimal expiryCount = BigDecimal.valueOf(expiries.length); final BigDecimal defaultAmountAtExpiry = underlyingAmount.divide(expiryCount, BigDecimal.ROUND_DOWN); final BigDecimal spareAmountAtExpiry = defaultAmountAtExpiry.add(BigDecimal.ONE); int spareCount = underlyingAmount.subtract(defaultAmountAtExpiry.multiply(expiryCount)).intValue(); for (final Period bucketPeriod : expiries) { final ManageablePortfolioNode bucketNode = new ManageablePortfolioNode( bucketPeriod.toString().substring(1)); final LocalDate nowish = LocalDate.now().withDayOfMonth(20); //This avoids us picking different options every time this script is run final LocalDate targetExpiry = nowish.plus(bucketPeriod); final LocalDate chosenExpiry = optionsByExpiry.floorKey(targetExpiry); if (chosenExpiry == null) { s_logger.info("No options for {} on {}", targetExpiry, underlying); continue; } s_logger.info("Using time {} for bucket {} ({})", new Object[] { chosenExpiry, bucketPeriod, targetExpiry }); final Set<BloombergTickerParserEQOption> optionsAtExpiry = optionsByExpiry.get(chosenExpiry); final TreeMap<Double, Pair<BloombergTickerParserEQOption, BloombergTickerParserEQOption>> optionsByStrike = new TreeMap<>(); for (final BloombergTickerParserEQOption option : optionsAtExpiry) { // s_logger.info("option {}", option); final double key = option.getStrike(); Pair<BloombergTickerParserEQOption, BloombergTickerParserEQOption> pair = optionsByStrike.get(key); if (pair == null) { pair = Pair.of(null, null); } if (option.getOptionType() == OptionType.CALL) { pair = Pair.of(option, pair.getSecond()); } else { pair = Pair.of(pair.getFirst(), option); } optionsByStrike.put(key, pair); } //cascading collar? final BigDecimal amountAtExpiry = spareCount-- > 0 ? spareAmountAtExpiry : defaultAmountAtExpiry; s_logger.info(" est strike {}", estimatedCurrentStrike); final Double[] strikes = optionsByStrike.keySet().toArray(new Double[0]); int strikeIndex = Arrays.binarySearch(strikes, estimatedCurrentStrike); if (strikeIndex < 0) { strikeIndex = -(1 + strikeIndex); } s_logger.info("strikes length {} index {} strike of index {}", new Object[] { Integer.valueOf(strikes.length), Integer.valueOf(strikeIndex), Double.valueOf(strikes[strikeIndex]) }); int minIndex = strikeIndex - _numOptions; minIndex = Math.max(0, minIndex); int maxIndex = strikeIndex + _numOptions; maxIndex = Math.min(strikes.length - 1, maxIndex); s_logger.info("min {} max {}", Integer.valueOf(minIndex), Integer.valueOf(maxIndex)); final StringBuffer sb = new StringBuffer("strikes: ["); for (int j = minIndex; j <= maxIndex; j++) { sb.append(" "); sb.append(strikes[j]); } sb.append(" ]"); s_logger.info(sb.toString()); //Short Calls final ArrayList<Pair<BloombergTickerParserEQOption, BloombergTickerParserEQOption>> calls = new ArrayList<Pair<BloombergTickerParserEQOption, BloombergTickerParserEQOption>>(); for (int j = minIndex; j < strikeIndex; j++) { final Pair<BloombergTickerParserEQOption, BloombergTickerParserEQOption> pair = optionsByStrike .get(strikes[j]); if (pair == null) { throw new OpenGammaRuntimeException("no pair for strike" + strikes[j]); } calls.add(pair); } spreadOptions(bucketNode, calls, OptionType.CALL, -1, tickersToLoad, amountAtExpiry, includeUnderlying, calls.size()); // Long Puts final ArrayList<Pair<BloombergTickerParserEQOption, BloombergTickerParserEQOption>> puts = new ArrayList<Pair<BloombergTickerParserEQOption, BloombergTickerParserEQOption>>(); for (int j = strikeIndex + 1; j <= maxIndex; j++) { final Pair<BloombergTickerParserEQOption, BloombergTickerParserEQOption> pair = optionsByStrike .get(strikes[j]); if (pair == null) { throw new OpenGammaRuntimeException("no pair for strike" + strikes[j]); } puts.add(pair); } spreadOptions(bucketNode, puts, OptionType.PUT, 1, tickersToLoad, amountAtExpiry, includeUnderlying, puts.size()); if (bucketNode.getChildNodes().size() + bucketNode.getPositionIds().size() > 0) { equityNode.addChildNode(bucketNode); //Avoid generating empty nodes } } for (final ExternalId optionTicker : tickersToLoad) { final ManageableSecurity loaded = getOrLoadSecurity(optionTicker); if (loaded == null) { throw new OpenGammaRuntimeException("Unexpected option type " + loaded); } //TODO [LAPANA-29] Should be able to do this for index options too if (includeUnderlying) { try { final HistoricalTimeSeriesInfoDocument loadedTs = getOrLoadTimeSeries(optionTicker, loaded.getExternalIdBundle()); if (loadedTs == null) { throw new OpenGammaRuntimeException("Failed to get time series for " + loaded); } } catch (final Exception ex) { s_logger.info("Failed to get time series for " + loaded, ex); } } } if (equityNode.getPositionIds().size() + equityNode.getChildNodes().size() > 0) { rootNode.addChildNode(equityNode); } }
From source file:eu.eidas.node.utils.EidasNodeErrorUtil.java
private static boolean isErrorCodeDisabledForSamlGeneration(final String errorCode) { if (Arrays.binarySearch(EIDAS_ERRORS_NO_SAML_GENERATION, errorCode) >= 0) { return true; }// w w w .j a v a 2 s .c o m return false; }
From source file:com.cg.mapreduce.fpgrowth.mahout.fpm.fpgrowth.FPGrowth.java
private static FrequentPatternMaxHeap growthBottomUp(FPTree tree, MutableLong minSupportMutable, int k, FPTreeDepthCache treeCache, int level, boolean conditionalOfCurrentAttribute, int currentAttribute, StatusUpdater updater) {/*from ww w . j a va 2s. c o m*/ FrequentPatternMaxHeap frequentPatterns = new FrequentPatternMaxHeap(k, false); if (!conditionalOfCurrentAttribute) { int index = Arrays.binarySearch(tree.getHeaderTableAttributes(), currentAttribute); if (index < 0) { return frequentPatterns; } else { int attribute = tree.getAttributeAtIndex(index); long count = tree.getHeaderSupportCount(attribute); if (count < minSupportMutable.longValue()) { return frequentPatterns; } } } if (tree.singlePath()) { return generateSinglePathPatterns(tree, k, minSupportMutable.longValue()); } updater.update("Bottom Up FP Growth"); for (int i = tree.getHeaderTableCount() - 1; i >= 0; i--) { int attribute = tree.getAttributeAtIndex(i); long count = tree.getHeaderSupportCount(attribute); if (count < minSupportMutable.longValue()) { continue; } FPTree conditionalTree = treeCache.getTree(level); FrequentPatternMaxHeap returnedPatterns; if (conditionalOfCurrentAttribute) { traverseAndBuildConditionalFPTreeData(tree.getHeaderNext(attribute), minSupportMutable.longValue(), conditionalTree, tree); returnedPatterns = growthBottomUp(conditionalTree, minSupportMutable, k, treeCache, level + 1, true, currentAttribute, updater); frequentPatterns = mergeHeap(frequentPatterns, returnedPatterns, attribute, count, true); } else { if (attribute == currentAttribute) { traverseAndBuildConditionalFPTreeData(tree.getHeaderNext(attribute), minSupportMutable.longValue(), conditionalTree, tree); returnedPatterns = growthBottomUp(conditionalTree, minSupportMutable, k, treeCache, level + 1, true, currentAttribute, updater); frequentPatterns = mergeHeap(frequentPatterns, returnedPatterns, attribute, count, true); } else if (attribute > currentAttribute) { traverseAndBuildConditionalFPTreeData(tree.getHeaderNext(attribute), minSupportMutable.longValue(), conditionalTree, tree); returnedPatterns = growthBottomUp(conditionalTree, minSupportMutable, k, treeCache, level + 1, false, currentAttribute, updater); frequentPatterns = mergeHeap(frequentPatterns, returnedPatterns, attribute, count, false); } } if (frequentPatterns.isFull() && minSupportMutable.longValue() < frequentPatterns.leastSupport()) { minSupportMutable.setValue(frequentPatterns.leastSupport()); } } return frequentPatterns; }
From source file:de.tap.easy_xkcd.utils.PrefHelper.java
public boolean checkRead(int number) { String read = sharedPrefs.getString(WHATIF_READ, ""); if (read.equals("")) { return false; }// ww w . jav a 2s.c o m String[] readList = Favorites.sortArray(read.split(",")); int[] readInt = new int[readList.length]; for (int i = 0; i < readInt.length; i++) { readInt[i] = Integer.parseInt(readList[i]); } int a = Arrays.binarySearch(readInt, number); return (a >= 0); }
From source file:org.zenoss.zep.index.impl.solr.SolrQueryBuilder.java
private static String escape(String s, char[] escaped, boolean quote) { StringBuilder sb = new StringBuilder(); final int len = s.length(); boolean whitespace = false; for (int i = 0; i < len; i++) { final char c = s.charAt(i); if (Character.isWhitespace(c)) whitespace = true;/* ww w . j av a 2s .co m*/ if (Arrays.binarySearch(escaped, c) >= 0) sb.append('\\'); sb.append(c); } if (quote && (whitespace || sb.length() == 0)) return '"' + sb.append('"').toString(); else return sb.toString(); }
From source file:net.bull.javamelody.internal.model.JavaInformations.java
public static List<ThreadInformations> buildThreadInformationsList() { final ThreadMXBean threadBean = ManagementFactory.getThreadMXBean(); final Map<Thread, StackTraceElement[]> stackTraces = Thread.getAllStackTraces(); final List<Thread> threads = new ArrayList<Thread>(stackTraces.keySet()); // si "1.6.0_01".compareTo(Parameters.JAVA_VERSION) > 0; // on rcuprait les threads sans stack trace en contournant bug 6434648 avant 1.6.0_01 // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6434648 // hormis pour le thread courant qui obtient sa stack trace diffremment sans le bug // threads = getThreadsFromThreadGroups(); // final Thread currentThread = Thread.currentThread(); // stackTraces = Collections.singletonMap(currentThread, currentThread.getStackTrace()); final boolean cpuTimeEnabled = threadBean.isThreadCpuTimeSupported() && threadBean.isThreadCpuTimeEnabled(); final long[] deadlockedThreads = getDeadlockedThreads(threadBean); final List<ThreadInformations> threadInfosList = new ArrayList<ThreadInformations>(threads.size()); // hostAddress rcupr ici car il peut y avoir plus de 20000 threads final String hostAddress = Parameters.getHostAddress(); for (final Thread thread : threads) { final StackTraceElement[] stackTraceElements = stackTraces.get(thread); final List<StackTraceElement> stackTraceElementList = stackTraceElements == null ? null : new ArrayList<StackTraceElement>(Arrays.asList(stackTraceElements)); final long cpuTimeMillis; final long userTimeMillis; if (cpuTimeEnabled) { cpuTimeMillis = threadBean.getThreadCpuTime(thread.getId()) / 1000000; userTimeMillis = threadBean.getThreadUserTime(thread.getId()) / 1000000; } else {//from ww w.ja va 2 s. c o m cpuTimeMillis = -1; userTimeMillis = -1; } final boolean deadlocked = deadlockedThreads != null && Arrays.binarySearch(deadlockedThreads, thread.getId()) >= 0; // stackTraceElementList est une ArrayList et non unmodifiableList pour lisibilit xml threadInfosList.add(new ThreadInformations(thread, stackTraceElementList, cpuTimeMillis, userTimeMillis, deadlocked, hostAddress)); } // on retourne ArrayList et non unmodifiableList pour lisibilit du xml par xstream return threadInfosList; }
From source file:aldenjava.opticalmapping.data.data.DataNode.java
/** * Search the refp index signals using the binary search algorithm * /*from w w w.j a va2 s. c o m*/ * @param pos * Specified position * @return the refp index of the signal at the specified position, or the refp index of the <code>insertion point</code> if the signal does not exist * @see findExactRefpIndex(long) */ public int findRefpIndex(long pos) { int index = Arrays.binarySearch(refp, pos); // index points to the last refp just larger than or equal to start if (index < 0) { index = (index + 1) * -1; } else { while (index >= 0 && refp[index] == pos) index--; if (index < 0) index = 0; else index++; } return index; }
From source file:com.opengamma.analytics.financial.interestrate.swaption.provider.SwaptionPhysicalFixedIborLMMDDMethod.java
/** * Computes the present value sensitivity to LMM volatility parameters. * @param swaption The (physical delivery) swaption. * @param lmmData The LMM and multi-curves provider. * @return The sensitivity./*from ww w . j ava 2 s . c o m*/ */ public double[][] presentValueLMMSensitivity(final SwaptionPhysicalFixedIbor swaption, final LiborMarketModelDisplacedDiffusionProviderInterface lmmData) { ArgumentChecker.notNull(swaption, "Swaption"); ArgumentChecker.notNull(lmmData, "LMM provider"); final Currency ccy = swaption.getCurrency(); final MulticurveProviderInterface multicurves = lmmData.getMulticurveProvider(); final LiborMarketModelDisplacedDiffusionParameters parameters = lmmData.getLMMParameters(); // 1. Swaption CFE preparation final AnnuityPaymentFixed cfe = swaption.getUnderlyingSwap().accept(CFEC, multicurves); final int nbCFInit = cfe.getNumberOfPayments(); final double multFact = Math.signum(cfe.getNthPayment(0).getAmount()); final boolean isCall = (cfe.getNthPayment(0).getAmount() < 0); final double[] cftInit = new double[nbCFInit]; final double[] cfaInit = new double[nbCFInit]; for (int loopcf = 0; loopcf < nbCFInit; loopcf++) { cftInit[loopcf] = cfe.getNthPayment(loopcf).getPaymentTime(); cfaInit[loopcf] = cfe.getNthPayment(loopcf).getAmount() * -multFact; } final double timeToExpiry = swaption.getTimeToExpiry(); // 2. Model data final int nbFactor = parameters.getNbFactor(); final double[][] volLMM = parameters.getVolatility(); final double[] timeLMM = parameters.getIborTime(); // 3. Link cfe dates to lmm final int[] indCFDate = new int[nbCFInit]; int indStart = nbCFInit - 1; int indEnd = 0; for (int loopcf = 0; loopcf < nbCFInit; loopcf++) { indCFDate[loopcf] = Arrays.binarySearch(timeLMM, cftInit[loopcf]); if (indCFDate[loopcf] < 0) { if (timeLMM[-indCFDate[loopcf] - 1] - cftInit[loopcf] < TIME_TOLERANCE) { indCFDate[loopcf] = -indCFDate[loopcf] - 1; } else { if (cftInit[loopcf] - timeLMM[-indCFDate[loopcf] - 2] < TIME_TOLERANCE) { indCFDate[loopcf] = -indCFDate[loopcf] - 2; } else { Validate.isTrue(true, "Instrument time incompatible with LMM"); } } } if (indCFDate[loopcf] < indStart) { indStart = indCFDate[loopcf]; } if (indCFDate[loopcf] > indEnd) { indEnd = indCFDate[loopcf]; } } final int nbCF = indEnd - indStart + 1; final double[] cfa = new double[nbCF]; for (int loopcf = 0; loopcf < nbCFInit; loopcf++) { cfa[indCFDate[loopcf] - indStart] = cfaInit[loopcf]; } final double[] cft = new double[nbCF]; System.arraycopy(timeLMM, indStart, cft, 0, nbCF); final double[] dfLMM = new double[nbCF]; for (int loopcf = 0; loopcf < nbCF; loopcf++) { dfLMM[loopcf] = multicurves.getDiscountFactor(ccy, cft[loopcf]); } final double[][] gammaLMM = new double[nbCF - 1][nbFactor]; final double[] deltaLMM = new double[nbCF - 1]; System.arraycopy(parameters.getAccrualFactor(), indStart, deltaLMM, 0, nbCF - 1); final double[] aLMM = new double[nbCF - 1]; System.arraycopy(parameters.getDisplacement(), indStart, aLMM, 0, nbCF - 1); final double[] liborLMM = new double[nbCF - 1]; final double amr = parameters.getMeanReversion(); for (int loopcf = 0; loopcf < nbCF - 1; loopcf++) { gammaLMM[loopcf] = volLMM[indStart + loopcf]; liborLMM[loopcf] = (dfLMM[loopcf] / dfLMM[loopcf + 1] - 1.0d) / deltaLMM[loopcf]; } // TODO: 4. cfe modification (for roller coasters) final double[] cfaMod = new double[nbCF + 1]; final double cfaMod0 = cfa[0]; cfaMod[0] = cfaMod0; // modified strike cfaMod[1] = 0.0; System.arraycopy(cfa, 1, cfaMod, 2, nbCF - 1); // 5. Pricing algorithm final double[] p0 = new double[nbCF]; final double[] dP = new double[nbCF]; double b0 = 0; for (int loopcf = 0; loopcf < nbCF; loopcf++) { p0[loopcf] = dfLMM[loopcf] / dfLMM[0]; dP[loopcf] = cfaMod[loopcf + 1] * p0[loopcf]; b0 += dP[loopcf]; } final double bK = -cfaMod0; final double bM = (b0 + bK) / 2.0d; final double[] rate0Ratio = new double[nbCF - 1]; final double[][] mu0 = new double[nbCF - 1][nbFactor]; for (int loopcf = 0; loopcf < nbCF - 1; loopcf++) { rate0Ratio[loopcf] = (liborLMM[loopcf] + aLMM[loopcf]) / (liborLMM[loopcf] + 1 / deltaLMM[loopcf]); } for (int loopfact = 0; loopfact < nbFactor; loopfact++) { mu0[0][loopfact] = rate0Ratio[0] * gammaLMM[0][loopfact]; } for (int loopcf = 1; loopcf < nbCF - 1; loopcf++) { for (int loopfact = 0; loopfact < nbFactor; loopfact++) { mu0[loopcf][loopfact] = mu0[loopcf - 1][loopfact] + rate0Ratio[loopcf] * gammaLMM[loopcf][loopfact]; } } final double meanReversionImpact = (Math.exp(2.0d * amr * timeToExpiry) - 1.0d) / (2.0d * amr); final double[] tau = new double[nbCF]; final double[] tau2 = new double[nbCF]; for (int loopcf = 0; loopcf < nbCF - 1; loopcf++) { for (int loopfact = 0; loopfact < nbFactor; loopfact++) { tau2[loopcf + 1] += mu0[loopcf][loopfact] * mu0[loopcf][loopfact]; } tau2[loopcf + 1] = tau2[loopcf + 1] * meanReversionImpact; tau[loopcf + 1] = Math.sqrt(tau2[loopcf + 1]); } double sumNum = -bM; double sumDen = 0; for (int loopcf = 0; loopcf < nbCF; loopcf++) { sumNum += dP[loopcf] - dP[loopcf] * tau2[loopcf] / 2.0; sumDen += dP[loopcf] * tau[loopcf]; } final double xBar = sumNum / sumDen; final double[] pM = new double[nbCF]; for (int loopcf = 0; loopcf < nbCF; loopcf++) { pM[loopcf] = p0[loopcf] * (1 - xBar * tau[loopcf] - tau2[loopcf] / 2.0); } final double[] liborM = new double[nbCF - 1]; final double[] alphaM = new double[nbCF]; for (int loopcf = 0; loopcf < nbCF - 1; loopcf++) { liborM[loopcf] = (pM[loopcf] / pM[loopcf + 1] - 1.0d) / deltaLMM[loopcf]; } for (int loopcf = 0; loopcf < nbCF; loopcf++) { alphaM[loopcf] = cfaMod[loopcf + 1] * pM[loopcf] / bM; } final double[] rateMRatio = new double[nbCF - 1]; final double[][] muM = new double[nbCF - 1][nbFactor]; for (int loopcf = 0; loopcf < nbCF - 1; loopcf++) { rateMRatio[loopcf] = (liborM[loopcf] + aLMM[loopcf]) / (liborM[loopcf] + 1 / deltaLMM[loopcf]); } for (int loopfact = 0; loopfact < nbFactor; loopfact++) { muM[0][loopfact] = rateMRatio[0] * gammaLMM[0][loopfact]; } for (int loopcf = 1; loopcf < nbCF - 1; loopcf++) { for (int loopfact = 0; loopfact < nbFactor; loopfact++) { muM[loopcf][loopfact] = muM[loopcf - 1][loopfact] + rateMRatio[loopcf] * gammaLMM[loopcf][loopfact]; } } double normSigmaM = 0; final double[] sigmaM = new double[nbFactor]; for (int loopfact = 0; loopfact < nbFactor; loopfact++) { for (int loopcf = 0; loopcf < nbCF - 1; loopcf++) { sigmaM[loopfact] += alphaM[loopcf + 1] * muM[loopcf][loopfact]; } normSigmaM += sigmaM[loopfact] * sigmaM[loopfact]; } final double impliedBlackVol = Math.sqrt(normSigmaM * meanReversionImpact); final EuropeanVanillaOption option = new EuropeanVanillaOption(bK, 1, isCall); final BlackPriceFunction blackFunction = new BlackPriceFunction(); final BlackFunctionData dataBlack = new BlackFunctionData(b0, 1.0, impliedBlackVol); final double[] blkAdjoint = blackFunction.getPriceAdjoint(option, dataBlack); // Backward sweep final double pvBar = 1.0; final double impliedBlackVolBar = dfLMM[0] * blkAdjoint[2] * pvBar; final double normSigmaMBar = meanReversionImpact / (2.0 * impliedBlackVol) * impliedBlackVolBar; final double[] sigmaMBar = new double[nbFactor]; for (int loopfact = 0; loopfact < nbFactor; loopfact++) { sigmaMBar[loopfact] = 2 * sigmaM[loopfact] * normSigmaMBar; } final double[][] muMBar = new double[nbCF - 1][nbFactor]; for (int loopcf = 0; loopcf < nbCF - 1; loopcf++) { for (int loopfact = 0; loopfact < nbFactor; loopfact++) { muMBar[loopcf][loopfact] = alphaM[loopcf + 1] * sigmaMBar[loopfact]; } } for (int loopcf = nbCF - 3; loopcf >= 0; loopcf--) { for (int loopfact = 0; loopfact < nbFactor; loopfact++) { muMBar[loopcf][loopfact] += muMBar[loopcf + 1][loopfact]; } } final double[] rateMRatioBar = new double[nbCF - 1]; for (int loopcf = 0; loopcf < nbCF - 1; loopcf++) { for (int loopfact = 0; loopfact < nbFactor; loopfact++) { rateMRatioBar[loopcf] += gammaLMM[loopcf][loopfact] * muMBar[loopcf][loopfact]; } } final double[] alphaMBar = new double[nbCF]; for (int loopfact = 0; loopfact < nbFactor; loopfact++) { for (int loopcf = 0; loopcf < nbCF - 1; loopcf++) { alphaMBar[loopcf + 1] += muM[loopcf][loopfact] * sigmaMBar[loopfact]; } } final double[] liborMBar = new double[nbCF - 1]; for (int loopcf = 0; loopcf < nbCF - 1; loopcf++) { liborMBar[loopcf] = ((liborM[loopcf] + 1 / deltaLMM[loopcf]) - (liborM[loopcf] + aLMM[loopcf])) / ((liborM[loopcf] + 1 / deltaLMM[loopcf]) * (liborM[loopcf] + 1 / deltaLMM[loopcf])) * rateMRatioBar[loopcf]; } final double[] pMBar = new double[nbCF]; for (int loopcf = 0; loopcf < nbCF - 1; loopcf++) { pMBar[loopcf] += 1.0 / pM[loopcf + 1] / deltaLMM[loopcf] * liborMBar[loopcf]; pMBar[loopcf + 1] += -pM[loopcf] / (pM[loopcf + 1] * pM[loopcf + 1]) / deltaLMM[loopcf] * liborMBar[loopcf]; } for (int loopcf = 0; loopcf < nbCF; loopcf++) { pMBar[loopcf] += cfaMod[loopcf + 1] / bM * alphaMBar[loopcf]; } double xBarBar = 0.0; for (int loopcf = 0; loopcf < nbCF; loopcf++) { xBarBar += -p0[loopcf] * tau[loopcf] * pMBar[loopcf]; } final double sumNumBar = 1.0 / sumDen * xBarBar; final double sumDenBar = -sumNum / (sumDen * sumDen) * xBarBar; final double[] tauBar = new double[nbCF]; for (int loopcf = 0; loopcf < nbCF; loopcf++) { tauBar[loopcf] = -p0[loopcf] * xBar * pMBar[loopcf]; } for (int loopcf = 0; loopcf < nbCF; loopcf++) { tauBar[loopcf] += dP[loopcf] * sumDenBar; } final double[] tau2Bar = new double[nbCF]; for (int loopcf = 0; loopcf < nbCF; loopcf++) { tau2Bar[loopcf] = -p0[loopcf] / 2.0 * pMBar[loopcf]; } for (int loopcf = 0; loopcf < nbCF; loopcf++) { tau2Bar[loopcf] += -dP[loopcf] / 2.0 * sumNumBar; } for (int loopcf = 0; loopcf < nbCF - 1; loopcf++) { tau2Bar[loopcf + 1] += 1 / 2.0 / tau[loopcf + 1] * tauBar[loopcf + 1]; } final double[][] mu0Bar = new double[nbCF - 1][nbFactor]; for (int loopcf = 0; loopcf < nbCF - 1; loopcf++) { for (int loopfact = 0; loopfact < nbFactor; loopfact++) { mu0Bar[loopcf][loopfact] = 2.0 * mu0[loopcf][loopfact] * meanReversionImpact * tau2Bar[loopcf + 1]; } } for (int loopcf = nbCF - 3; loopcf >= 0; loopcf--) { for (int loopfact = 0; loopfact < nbFactor; loopfact++) { mu0Bar[loopcf][loopfact] += mu0Bar[loopcf + 1][loopfact]; } } final double[][] gammaLMMBar = new double[nbCF - 1][nbFactor]; for (int loopfact = 0; loopfact < nbFactor; loopfact++) { gammaLMMBar[0][loopfact] = rateMRatio[0] * muMBar[0][loopfact]; } for (int loopcf = 1; loopcf < nbCF - 1; loopcf++) { for (int loopfact = 0; loopfact < nbFactor; loopfact++) { gammaLMMBar[loopcf][loopfact] += rateMRatio[loopcf] * muMBar[loopcf][loopfact]; } } for (int loopfact = 0; loopfact < nbFactor; loopfact++) { gammaLMMBar[0][loopfact] += rate0Ratio[0] * mu0Bar[0][loopfact]; } for (int loopcf = 1; loopcf < nbCF - 1; loopcf++) { for (int loopfact = 0; loopfact < nbFactor; loopfact++) { gammaLMMBar[loopcf][loopfact] += rate0Ratio[loopcf] * mu0Bar[loopcf][loopfact]; } } final double[][] volLMMBar = new double[volLMM.length][nbFactor]; for (int loopcf = 0; loopcf < nbCF - 1; loopcf++) { volLMMBar[indStart + loopcf] = gammaLMMBar[loopcf]; } return volLMMBar; }
From source file:com.github.checkstyle.NotesBuilder.java
/** * Returns issue label for release notes. * @param issue issue./*from w w w . j a v a2 s .co m*/ * @return issue label for release notes * @throws IOException if an I/o error occurs. */ private static String getIssueLabelFrom(GHIssue issue) throws IOException { final Collection<GHLabel> issueLabels = issue.getLabels(); final GHLabel label = Iterables.tryFind(issueLabels, new Predicate<GHLabel>() { @Override public boolean apply(GHLabel input) { return Arrays.binarySearch(Constants.ISSUE_LABELS, input.getName()) != -1; } }).orNull(); final String issueLabelName; if (label == null) { issueLabelName = ""; } else { issueLabelName = label.getName(); } return issueLabelName; }