List of usage examples for java.lang Double doubleValue
@HotSpotIntrinsicCandidate public double doubleValue()
From source file:eu.optimis.ecoefficiencytool.core.tools.CO2Converter.java
/** * Returns the amount of CO2 gr. emmited to the atmosphere in order to * produce the amount of power specified by power. This function takes into * account the nature of the energy being consumed by the datacenter * facilities (i.e. brown/green, having a 0 CO2 footpring for green energy) * and, among the brown energy, its origin (coal, gas, fuel, etc.). It also * takes into account the presence of energy credits acquired by the * Infrastructure Provider.//from w ww . j a v a 2 s. c o m * * @param power Amount of power expressed in Watts. * @return */ public static double getCO2FromPower(double power) { //A tiny amount of CO2 is returned (to avoid having Infinity ecological efficiency values) if (EnergyCreditsManager.isDatacenterRunningOnGreen()) { return 0.000001; } PropertiesConfiguration configEnergy = ConfigManager .getPropertiesConfiguration(ConfigManager.ENERGY_SOURCES_CONFIG_FILE); //Calculate which part of the consumed power is brown (green has no emissions). double brownPower = power * configEnergy.getDouble("brown.percentage") / 100.0; //Calculate the amount of gr of CO2 emitted to produce this brown energy. double totalGrS = 0.0, totalPercentage = 0.0; Iterator it = configEnergy.getKeys("emissions"); while (it.hasNext()) { String key = (String) it.next(); String energySource = key.split("\\.")[1]; double emissions = ((double) configEnergy.getInt(key)) / 3600000.0; //From gr/(kW*h) to gr/(W*s) Double percentage = configEnergy.getDouble("percentage." + energySource); if (percentage == null) { log.warn("Percentage associated to " + energySource + " was not found."); continue; } totalPercentage += percentage; totalGrS += percentage.doubleValue() * brownPower * emissions; } if (totalPercentage != 100.0) { log.warn("Total percentage wasn't 100.0. Check the energysources.properties configuration file."); } log.debug("Emitted " + totalGrS + " gr/s of CO2 to deliver " + power + "W of power (" + brownPower + "W brown)."); return totalGrS; }
From source file:com.github.gdfm.shobaidogu.StatsUtils.java
/** * Computes the Jensen-Shannon divergence between two distributions. The distributions are represented by maps with * double values./*w w w. j a v a2 s . c om*/ * * @param p * the first distribution. * @param q * the second distribution. * @return the JS divergence. */ public static <K, V extends Number> double JSdivergence(Map<K, V> p, Map<K, V> q) { checkNotNull(p); checkNotNull(q); Map<K, Double> m = Maps.newHashMap(); // compute m = (p + q) / 2 for (Entry<K, V> pi : p.entrySet()) { m.put(pi.getKey(), pi.getValue().doubleValue() / 2); } for (Entry<K, V> qi : q.entrySet()) { Double mi = m.get(qi.getKey()); if (mi == null) mi = 0.0; m.put(qi.getKey(), qi.getValue().doubleValue() / 2 + mi.doubleValue()); } double jsd = (KLdivergence(p, m) + KLdivergence(q, m)) / 2; return jsd; }
From source file:de.mpg.mpi_inf.bioinf.netanalyzer.ui.charts.MyLogarithmicAxis.java
/** * Gives the <code>String</code> representation of the given number. * //from w w w . ja v a 2 s .co m * @param aValue Number to be converted to <code>String</code>. * @param aScientific Flag indicating if scientific notation is preferred. * @return String representation of <code>aValue</code>. */ private static String toString(Double aValue, boolean aScientific) { return toString(aValue.doubleValue(), aScientific); }
From source file:net.sourceforge.fenixedu.util.InquiriesUtil.java
public static String getTdClass(final Double val, final String[] classes, final String defaultClass, final double[] values) { if (val == null) { return defaultClass; }/* w ww. j a v a 2 s . c o m*/ if (classes.length == (values.length - 1)) { final double v = val.doubleValue(); for (int i = 0; i < classes.length; i++) { if ((v >= values[i]) && (v < values[i + 1])) { return classes[i]; } } } return defaultClass; }
From source file:org.kalypso.model.wspm.ewawi.utils.GewShape.java
public static GewShapeRow findRow(final Geometry geometry, final List<GewShapeRow> rows, final XyzEwawiLogger logger, final String category) { final SHP2JTS shp2jts = new SHP2JTS(geometry.getFactory()); /* Collect the distances, so if none intersects, we can use them to return the nearest. */ final SortedMap<Double, GewShapeRow> distances = new TreeMap<>(); /* Check, if intersecting. */ for (final GewShapeRow row : rows) { final ISHPGeometry shape = row.getShape(); final Geometry value = shp2jts.transform(shape); if (value == null) continue; if (value.intersects(geometry)) { System.out.println("Geometrie schneidet einen Gewsserabschnitt, dieser wird verwendet."); return row; }// w ww .j a va2s .c o m final double distance = value.distance(geometry); distances.put(new Double(distance), row); } if (distances.size() == 0) { final String message = "Keine Gewsserabschnitte verfgbar."; System.out.println(message); if (logger != null) { final Point centroid = geometry.getCentroid(); logger.logXyzLine(centroid.getX(), centroid.getY(), -9999.0, message, category, -9999.0); } return null; } final Entry<Double, GewShapeRow> entry = distances.entrySet().iterator().next(); final Double key = entry.getKey(); final GewShapeRow value = entry.getValue(); final String message = String.format( "Geometrie schneidet keinen Gewsserabschnitt, nhester wird verwendet. Distanz: %f", key.doubleValue()); System.out.println(message); if (logger != null) { final Point centroid = geometry.getCentroid(); logger.logXyzLine(centroid.getX(), centroid.getY(), -9999.0, message, category, key.doubleValue()); } return value; }
From source file:Main.java
/** * <p>Converts an array of object Doubles to primitives handling {@code null}.</p> * * <p>This method returns {@code null} for a {@code null} input array.</p> * * @param array a {@code Double} array, may be {@code null} * @param valueForNull the value to insert if {@code null} found * @return a {@code double} array, {@code null} if null array input */// w w w . j a v a2 s. c o m public static double[] toPrimitive(Double[] array, double valueForNull) { if (array == null) { return null; } else if (array.length == 0) { return EMPTY_DOUBLE_ARRAY; } final double[] result = new double[array.length]; for (int i = 0; i < array.length; i++) { Double b = array[i]; result[i] = (b == null ? valueForNull : b.doubleValue()); } return result; }
From source file:com.jdom.junit.utils.AbstractFixture.java
/** * Get a randomized value./*w w w .j av a 2 s . c o m*/ * * @param value * the value to randomize * @param salt * the randomizer to use * @return the randomized value */ public static Double getSaltedValue(Double value, int salt) { Double retValue; if (salt == 0) { retValue = value; } else { retValue = new Double(value.doubleValue() * salt * salt / 2 + DOUBLE_FACTOR); } return retValue; }
From source file:Main.java
/** * <p>Converts an array of object Doubles to primitives handling {@code null}.</p> * * <p>This method returns {@code null} for a {@code null} input array.</p> * * @param array a {@code Double} array, may be {@code null} * @param valueForNull the value to insert if {@code null} found * @return a {@code double} array, {@code null} if null array input */// w w w .j a v a 2 s . c o m public static double[] toPrimitive(final Double[] array, final double valueForNull) { if (array == null) { return null; } else if (array.length == 0) { return EMPTY_DOUBLE_ARRAY; } final double[] result = new double[array.length]; for (int i = 0; i < array.length; i++) { final Double b = array[i]; result[i] = (b == null ? valueForNull : b.doubleValue()); } return result; }
From source file:edu.isi.misd.scanner.network.modules.worker.processors.oceans.OceansLogisticRegressionProcessor.java
/** * Formats a double to a fixed (currently three) number of decimal places. *///from w ww. j av a 2 s . c o m public static double df(double a) { DecimalFormat f = new DecimalFormat(".000"); Double input = Double.valueOf(a); // check for special values so that they are not parsed if (input.equals(Double.NEGATIVE_INFINITY) || input.equals(Double.POSITIVE_INFINITY) || input.equals(Double.NaN)) { return input.doubleValue(); } return Double.parseDouble(f.format(input)); }
From source file:com.kingcore.framework.util.ConvertUtils.java
/** * ?//from w w w.j av a 2 s . c om * Create on 2003-6-18 * @param Double * @param int ??? * @return */ public static String formatNumber(Double d, int scalar) throws Exception { double temp = d.doubleValue(); return formatNumber(temp, scalar); }