List of usage examples for java.lang Double intValue
public int intValue()
From source file:com.galenframework.speclang2.reader.specs.SpecImageProcessor.java
private ImageFilter parseImageFilter(String filterText) { StringCharReader reader = new StringCharReader(filterText); String filterName = new ExpectWord().read(reader); Double value = new ExpectNumber().read(reader); if ("contrast".equals(filterName)) { return new ContrastFilter(value.intValue()); } else if ("blur".equals(filterName)) { return new BlurFilter(value.intValue()); } else if ("denoise".equals(filterName)) { return new DenoiseFilter(value.intValue()); } else if ("saturation".equals(filterName)) { return new SaturationFilter(value.intValue()); } else if ("quantinize".equals(filterName)) { return new QuantinizeFilter(value.intValue()); } else//from w w w . j a v a 2 s.c o m throw new SyntaxException("Unknown image filter: " + filterName); }
From source file:edu.scripps.fl.pubchem.xml.extract.XrefExtractor.java
public void checkXrefAgainstPanel(List<Xref> xrefs, List<Panel> panel) { for (Panel yy : panel) { for (int ii = 0; ii < xrefs.size(); ii++) { Xref xx = xrefs.get(ii);//from w ww . jav a2 s .com String type = xx.getXrefType(); if (type.equalsIgnoreCase("gene") || type.equalsIgnoreCase("protein") || type.equalsIgnoreCase("nucleotide")) { Double idD = Double.parseDouble(xx.getXrefValue().toString()); Integer id = idD.intValue(); if (type.equalsIgnoreCase("gene")) { List<Integer> genes = yy.getPanelGene(); if (genes != null) { if (genes.contains(id)) xrefs.remove(xx); } } else if (type.equalsIgnoreCase("protein") || type.equalsIgnoreCase("nucleotide")) { List<PanelTarget> targets = yy.getPanelTarget(); if (targets != null) { for (PanelTarget target : targets) { if (target.getPanelTargetGi().equals(id)) { xrefs.remove(xx); } } } } else if (type.equalsIgnoreCase("taxonomy")) { List<Integer> taxonomies = yy.getPanelTaxonomy(); if (taxonomies != null) { if (taxonomies.contains(id)) xrefs.remove(xx); } } } } } }
From source file:org.deeplearning4j.examples.recurrent.encdec.CorpusIterator.java
@Override public MultiDataSet next(int num) { int i = currentBatch * batchSize; int currentBatchSize = Math.min(batchSize, corpus.size() - i - 1); INDArray input = Nd4j.zeros(currentBatchSize, 1, rowSize); INDArray prediction = Nd4j.zeros(currentBatchSize, dictSize, rowSize); INDArray decode = Nd4j.zeros(currentBatchSize, dictSize, rowSize); INDArray inputMask = Nd4j.zeros(currentBatchSize, rowSize); // this mask is also used for the decoder input, the length is the same INDArray predictionMask = Nd4j.zeros(currentBatchSize, rowSize); for (int j = 0; j < currentBatchSize; j++) { List<Double> rowIn = new ArrayList<>(corpus.get(i)); Collections.reverse(rowIn); List<Double> rowPred = new ArrayList<>(corpus.get(i + 1)); rowPred.add(1.0); // add <eos> token // replace the entire row in "input" using NDArrayIndex, it's faster than putScalar(); input is NOT made of one-hot vectors // because of the embedding layer that accepts token indexes directly input.put(//from w w w.ja va 2 s . c o m new INDArrayIndex[] { NDArrayIndex.point(j), NDArrayIndex.point(0), NDArrayIndex.interval(0, rowIn.size()) }, Nd4j.create(ArrayUtils.toPrimitive(rowIn.toArray(new Double[0])))); inputMask.put(new INDArrayIndex[] { NDArrayIndex.point(j), NDArrayIndex.interval(0, rowIn.size()) }, Nd4j.ones(rowIn.size())); predictionMask.put( new INDArrayIndex[] { NDArrayIndex.point(j), NDArrayIndex.interval(0, rowPred.size()) }, Nd4j.ones(rowPred.size())); // prediction (output) and decode ARE one-hots though, I couldn't add an embedding layer on top of the decoder and I'm not sure // it's a good idea either double predOneHot[][] = new double[dictSize][rowPred.size()]; double decodeOneHot[][] = new double[dictSize][rowPred.size()]; decodeOneHot[2][0] = 1; // <go> token int predIdx = 0; for (Double pred : rowPred) { predOneHot[pred.intValue()][predIdx] = 1; if (predIdx < rowPred.size() - 1) { // put the same vals to decode with +1 offset except the last token that is <eos> decodeOneHot[pred.intValue()][predIdx + 1] = 1; } ++predIdx; } prediction.put(new INDArrayIndex[] { NDArrayIndex.point(j), NDArrayIndex.interval(0, dictSize), NDArrayIndex.interval(0, rowPred.size()) }, Nd4j.create(predOneHot)); decode.put(new INDArrayIndex[] { NDArrayIndex.point(j), NDArrayIndex.interval(0, dictSize), NDArrayIndex.interval(0, rowPred.size()) }, Nd4j.create(decodeOneHot)); ++i; } ++currentBatch; return new org.nd4j.linalg.dataset.MultiDataSet(new INDArray[] { input, decode }, new INDArray[] { prediction }, new INDArray[] { inputMask, predictionMask }, new INDArray[] { predictionMask }); }
From source file:dz.alkhwarizmix.winrak.java.model.vo.WinrakPosition.java
/** * http://www.movable-type.co.uk/scripts/latlong.html *//* w w w .j a v a 2s. co m*/ @Override public int distanceTo(final IWinrakPosition pos2) { final WinrakPosition pos1 = this; final Double R = 6371000.0; // metres final Double radLat1 = Math.toRadians(pos1.getLat()); final Double radLat2 = Math.toRadians(pos2.getLat()); final Double deltaLat = Math.toRadians(pos2.getLat() - pos1.getLat()); final Double deltaLng = Math.toRadians(pos2.getLng() - pos1.getLng()); final Double a = (Math.sin(deltaLat / 2) * Math.sin(deltaLat / 2)) + (Math.cos(radLat1) * Math.cos(radLat2) * Math.sin(deltaLng / 2) * Math.sin(deltaLng / 2)); final Double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); final Double d = R * c; return (d.intValue()); }
From source file:org.sonar.batch.compute.NewCoverageAggregator.java
void aggregate(DecoratorContext context, Metric metric, int maxPeriods) { int[] variations = { 0, 0, 0, 0, 0 }; boolean[] hasValues = { false, false, false, false, false }; for (Measure child : context.getChildrenMeasures(metric)) { for (int indexPeriod = 1; indexPeriod <= maxPeriods; indexPeriod++) { Double variation = child.getVariation(indexPeriod); if (variation != null) { variations[indexPeriod - 1] = variations[indexPeriod - 1] + variation.intValue(); hasValues[indexPeriod - 1] = true; }// w ww . j ava 2 s . c o m } } if (ArrayUtils.contains(hasValues, true)) { Measure measure = new Measure(metric); for (int index = 0; index < 5; index++) { if (hasValues[index]) { measure.setVariation(index + 1, (double) variations[index]); } } context.saveMeasure(measure); } }
From source file:com.hazelcast.simulator.visualiser.ui.Chart.java
private void updateDataSet(AggregatedDataSet dataSet) { plot.getDomainAxis().setAutoRange(true); plot.getRangeAxis().setAutoRange(true); plot.setDataset(dataSet);//from w ww. j a v a2 s.com Double horizontalUpperBound = plot.getDomainAxis().getRange().getUpperBound(); mainHorizontalSlider.setMaximum(horizontalUpperBound.intValue()); mainHorizontalSlider.setValue(0); mainHorizontalSlider.setValue((int) dataSet.getAutoScaleValue()); Double verticalUpperBound = plot.getRangeAxis().getRange().getUpperBound(); verticalSlider.setMaximum(verticalUpperBound.intValue()); verticalSlider.setValue(0); verticalSlider.setValue(verticalUpperBound.intValue()); }
From source file:org.motechproject.server.service.impl.ObsPredicate.java
public boolean evaluate(Object input) { if (input instanceof Obs) { Obs obs = (Obs) input;/* ww w .jav a 2 s .co m*/ Date obsDate = obs.getObsDatetime(); boolean afterMinDate = true; if (minDate != null) { afterMinDate = obsDate.after(minDate); } boolean beforeMaxDate = true; if (maxDate != null) { beforeMaxDate = obsDate.before(maxDate); } Double obsValue = obs.getValueNumeric(); boolean matchingValue = true; if (value != null && obsValue != null) { matchingValue = value.intValue() == obsValue.intValue(); } return afterMinDate && beforeMaxDate && matchingValue; } return false; }
From source file:at.tuwien.minimee.util.PslistWinParser.java
private WinProcessExecutionFootprint parseProcessLine(StringTokenizer tokenizer) { WinProcessExecutionFootprint pfp = new WinProcessExecutionFootprint(); int column = 1; for (column = 1; tokenizer.hasMoreTokens(); column++) { String strColumn = tokenizer.nextToken(" "); switch (column) { case 1: // Pid Double pid = parseSizeColumn(strColumn); pfp.setPid(pid.intValue()); break; case 2: // VM Double virt = parseSizeColumn(strColumn); pfp.setVirtualMemory(virt);//from w w w. j a v a 2 s. c o m break; case 3: // WS: working set break; case 4: // Private virtual memory Double pvmem = parseSizeColumn(strColumn); pfp.setPrivateVirtualMemory(pvmem); break; case 5: // Priv Pk Double privPeak = parseSizeColumn(strColumn); pfp.setPrivateVirtualMemoryPeak(privPeak); break; case 6: // Faults break; case 7: // NonP break; case 8: // Page break; default: continue; } } return pfp; }
From source file:com.galenframework.speclang2.specs.SpecImageProcessor.java
private int parseInt(StringCharReader reader) { Double value = Expectations.number().read(reader); if (value != null) { return value.intValue(); }/*from w w w . jav a 2 s . co m*/ return 0; }
From source file:com.quinsoft.zeidon.domains.DoubleDomain.java
@Override public Integer convertToInteger(Task task, AttributeDef attributeDef, Object internalValue) { if (internalValue == null) return null; Double d = (Double) internalValue; return d.intValue(); }