Example usage for java.util.concurrent.atomic AtomicInteger doubleValue

List of usage examples for java.util.concurrent.atomic AtomicInteger doubleValue

Introduction

In this page you can find the example usage for java.util.concurrent.atomic AtomicInteger doubleValue.

Prototype

public double doubleValue() 

Source Link

Document

Returns the current value of this AtomicInteger as a double after a widening primitive conversion, with memory effects as specified by VarHandle#getVolatile .

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    AtomicInteger atomicInteger = new AtomicInteger();

    System.out.println(atomicInteger.doubleValue());
}

From source file:jurls.core.becca.DefaultZiptie.java

public static double getGeneralizedMean(RealMatrix c, double exponent, int rowStart, int rowEnd, int colStart,
        int colEnd) {
    AtomicDouble s = new AtomicDouble(0);
    AtomicInteger n = new AtomicInteger(0);
    c.walkInOptimizedOrder(new DefaultRealMatrixPreservingVisitor() {
        @Override/*from  w w  w . j  ava  2s  .c o  m*/
        public void visit(int row, int column, double value) {
            s.addAndGet(Math.pow(value, exponent));
            n.incrementAndGet();
        }
    }, rowStart, rowEnd, colStart, colEnd);

    return (1.0 / n.doubleValue()) * Math.pow(s.doubleValue(), 1.0 / exponent);
}

From source file:jurls.core.becca.DefaultZiptie.java

public double getRowGeneralizedMean(RealMatrix c, Function<Integer, Double> rowEntryMultiplier, double exponent,
        int rowStart, int rowEnd, int column) {
    AtomicDouble s = new AtomicDouble(0);
    AtomicInteger n = new AtomicInteger(0);
    c.walkInOptimizedOrder(new DefaultRealMatrixPreservingVisitor() {
        @Override/*w ww .j  a v a2s .  c o  m*/
        public void visit(int row, int column, double value) {
            double a = Math.pow(value, exponent);
            double b = rowEntryMultiplier.apply(row);
            s.addAndGet(a * b);
            n.incrementAndGet();
        }
    }, rowStart, rowEnd, column, column);

    return (1.0 / n.doubleValue()) * Math.pow(s.doubleValue(), 1.0 / exponent);
}

From source file:com.github.tomakehurst.wiremock.matching.EqualToXmlPattern.java

@Override
public MatchResult match(final String value) {
    return new MatchResult() {
        @Override/*from   ww  w. j  a  va 2s .  c  om*/
        public boolean isExactMatch() {
            if (isNullOrEmpty(value)) {
                return false;
            }

            try {
                Diff diff = DiffBuilder.compare(Input.from(expectedValue)).withTest(value)
                        .withComparisonController(ComparisonControllers.StopWhenDifferent).ignoreWhitespace()
                        .ignoreComments().withDifferenceEvaluator(IGNORE_UNCOUNTED_COMPARISONS).build();

                return !diff.hasDifferences();
            } catch (XMLUnitException e) {
                notifier().info("Failed to process XML. " + e.getMessage() + "\nExpected:\n" + expectedValue
                        + "\n\nActual:\n" + value);
                return false;
            }
        }

        @Override
        public double getDistance() {
            if (isNullOrEmpty(value)) {
                return 1.0;
            }

            final AtomicInteger totalComparisons = new AtomicInteger(0);
            final AtomicInteger differences = new AtomicInteger(0);

            Diff diff = null;
            try {
                diff = DiffBuilder.compare(Input.from(expectedValue)).withTest(value).ignoreWhitespace()
                        .ignoreComments().withDifferenceEvaluator(IGNORE_UNCOUNTED_COMPARISONS)
                        .withComparisonListeners(new ComparisonListener() {
                            @Override
                            public void comparisonPerformed(Comparison comparison, ComparisonResult outcome) {
                                if (COUNTED_COMPARISONS.contains(comparison.getType())
                                        && comparison.getControlDetails().getValue() != null) {
                                    totalComparisons.incrementAndGet();
                                    if (outcome == ComparisonResult.DIFFERENT) {
                                        differences.incrementAndGet();
                                    }
                                }
                            }
                        }).build();
            } catch (XMLUnitException e) {
                notifier().info("Failed to process XML. " + e.getMessage() + "\nExpected:\n" + expectedValue
                        + "\n\nActual:\n" + value);
                return 1.0;
            }

            notifier().info(Joiner.on("\n").join(diff.getDifferences()));

            return differences.doubleValue() / totalComparisons.doubleValue();
        }
    };
}

From source file:org.deeplearning4j.models.glove.Glove.java

public void fit() {
    boolean cacheFresh = false;

    if (vocab() == null) {
        cacheFresh = true;/*from w  ww  .  j  a  va  2  s.  c  o m*/
        setVocab(new InMemoryLookupCache());
    }

    if (textVectorizer == null && cacheFresh) {
        InvertedIndex index = new LuceneInvertedIndex(vocab(), false, "glove-index");
        textVectorizer = new TfidfVectorizer.Builder().tokenize(tokenizerFactory).index(index).cache(vocab())
                .iterate(sentenceIterator).minWords(minWordFrequency).stopWords(stopWords).stem(stem).build();

        textVectorizer.fit();
    }

    if (sentenceIterator != null)
        sentenceIterator.reset();

    if (coOccurrences == null) {
        coOccurrences = new CoOccurrences.Builder().cache(vocab()).iterate(sentenceIterator)
                .symmetric(symmetric).tokenizer(tokenizerFactory).windowSize(windowSize).build();

        coOccurrences.fit();

    }

    if (lookupTable == null) {
        lookupTable = new GloveWeightLookupTable.Builder().cache(textVectorizer.vocab()).lr(learningRate)
                .vectorLength(layerSize).maxCount(maxCount).build();
    }

    if (lookupTable().getSyn0() == null)
        lookupTable().resetWeights();
    final List<Pair<String, String>> pairList = coOccurrences.coOccurrenceList();
    if (shuffle)
        Collections.shuffle(pairList, new java.util.Random());

    final AtomicInteger countUp = new AtomicInteger(0);
    final Counter<Integer> errorPerIteration = Util.parallelCounter();
    log.info("Processing # of co occurrences " + coOccurrences.numCoOccurrences());
    for (int i = 0; i < iterations; i++) {
        final AtomicInteger processed = new AtomicInteger(coOccurrences.numCoOccurrences());
        doIteration(i, pairList, errorPerIteration, processed, countUp);
        log.info("Processed " + countUp.doubleValue() + " out of " + (pairList.size() * iterations)
                + " error was " + errorPerIteration.getCount(i));

    }

}