List of usage examples for java.lang Math pow
@HotSpotIntrinsicCandidate public static double pow(double a, double b)
From source file:ch.unil.genescore.vegas.DistributionMethods.java
public static double chiSquared1dfInverseCumulativeProbabilityUpperTail(double p) { double p2 = p / 2; double q;/*from w w w . ja v a 2 s . co m*/ if (p2 < 1E-14) { double upper = normalInversionUpperTailApprox(p2); q = Math.pow(upper, 2); } else { q = chiSquared1df_.inverseCumulativeProbability(1 - p); } return (q); }
From source file:org.wallerlab.yoink.density.service.density.ElementVectorImpl.java
public Vector inverseZVector() { Vector inverseZVector = myVector3D.create(Math.pow(elementType.z1(), -1), Math.pow(elementType.z2(), -1), Math.pow(elementType.z3(), -1)); return inverseZVector; }
From source file:Main.java
/** * Returns the closest power-of-two number less than or equal to x. * * @param x input value/*from w w w. j a va2s .c om*/ * * @return the closest power-of-two number less then or equal to x */ public static long prevPow2(long x) { if (x < 1) { throw new IllegalArgumentException("x must be greater or equal 1"); } return (long) Math.pow(2, Math.floor(Math.log(x) / Math.log(2))); }
From source file:gob.dp.simco.comun.FunctionUtil.java
public static final double redondear(double numero, int decimales) { return Math.round(numero * Math.pow(10, decimales)) / Math.pow(10, decimales); }
From source file:Main.java
public static int itoa(int iSrc, byte[] buffer, int positionalNumber, int offset) { int i = offset; while (positionalNumber > 0) { int jesu = (int) Math.pow(10, positionalNumber - 1); int quotiont = iSrc / jesu; buffer[i] = (byte) (quotiont + '0'); int remainder = iSrc % jesu; positionalNumber--;/* www. j a v a 2s. c o m*/ i++; iSrc = remainder; } return positionalNumber; }
From source file:com.itemanalysis.psychometrics.kernel.SimplePluginBandwidth.java
public double value() { return 1.06 * sd.getResult() * Math.pow(sd.getN(), -0.2) * adjustmentFactor; }
From source file:com.opengamma.engine.view.NumberDeltaComparer.java
/** * Constructs a new {@link NumberDeltaComparer} for detecting differences to the given number of decimal places. * /*from w w w.ja v a 2 s .co m*/ * @param decimalPlaces * The number of places after the decimal point within which a change is considered to be a delta. If set to * 0, only the integral part of the values are considered. If set to a negative number, digits to the left of * the decimal point become insignificant. */ public NumberDeltaComparer(int decimalPlaces) { _decimalPlaces = decimalPlaces; _multiplier = Math.pow(10, decimalPlaces); }
From source file:de.termininistic.serein.examples.benchmarks.functions.multimodal.LevyFunction.java
@Override public double map(RealVector v) { double[] x = v.toArray(); double sum = Math.pow(Math.sin(Math.PI * w(x[0])), 2); for (int i = 0; i < x.length - 1; i++) { sum += Math.pow((w(x[i]) - 1), 2) * (1 + 10 * Math.pow(Math.sin(2 * Math.PI * w(x[0]) + 1), 2) + Math.pow(w(x[x.length - 1]) - 1, 2) * (1 + Math.pow(Math.sin(2 * Math.PI * w(x[x.length - 1]) + 1), 2))); }/*from w w w .j a v a2 s . c o m*/ return sum; }
From source file:SpringCompactGrid.java
/** * Create the GUI and show it. For thread safety, * this method should be invoked from the * event-dispatching thread./*from www . jav a2 s. co m*/ */ private static void createAndShowGUI() { JPanel panel = new JPanel(new SpringLayout()); int rows = 10; int cols = 10; for (int r = 0; r < rows; r++) { for (int c = 0; c < cols; c++) { int anInt = (int) Math.pow(r, c); JTextField textField = new JTextField(Integer.toString(anInt)); panel.add(textField); } } //Lay out the panel. SpringUtilities.makeCompactGrid(panel, //parent rows, cols, 3, 3, //initX, initY 3, 3); //xPad, yPad //Create and set up the window. JFrame frame = new JFrame("SpringCompactGrid"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Set up the content pane. panel.setOpaque(true); //content panes must be opaque frame.setContentPane(panel); //Display the window. frame.pack(); frame.setVisible(true); }
From source file:Main.java
/** * Creates an approximated cubic gradient using a multi-stop linear gradient. *///from w ww .j av a 2 s .com public static Drawable makeCubicGradientScrimDrawable(int baseColor, int numStops, int gravity) { // Generate a cache key by hashing together the inputs, based on the method described in the Effective Java book int cacheKeyHash = baseColor; cacheKeyHash = 31 * cacheKeyHash + numStops; cacheKeyHash = 31 * cacheKeyHash + gravity; Drawable cachedGradient = cubicGradientScrimCache.get(cacheKeyHash); if (cachedGradient != null) { return cachedGradient; } numStops = Math.max(numStops, 2); PaintDrawable paintDrawable = new PaintDrawable(); paintDrawable.setShape(new RectShape()); final int[] stopColors = new int[numStops]; int red = Color.red(baseColor); int green = Color.green(baseColor); int blue = Color.blue(baseColor); int alpha = Color.alpha(baseColor); for (int i = 0; i < numStops; i++) { float x = i * 1f / (numStops - 1); float opacity = constrain(0, 1, (float) Math.pow(x, 3)); stopColors[i] = Color.argb((int) (alpha * opacity), red, green, blue); } final float x0, x1, y0, y1; switch (gravity & Gravity.HORIZONTAL_GRAVITY_MASK) { case Gravity.LEFT: x0 = 1; x1 = 0; break; case Gravity.RIGHT: x0 = 0; x1 = 1; break; default: x0 = 0; x1 = 0; break; } switch (gravity & Gravity.VERTICAL_GRAVITY_MASK) { case Gravity.TOP: y0 = 1; y1 = 0; break; case Gravity.BOTTOM: y0 = 0; y1 = 1; break; default: y0 = 0; y1 = 0; break; } paintDrawable.setShaderFactory(new ShapeDrawable.ShaderFactory() { @Override public Shader resize(int width, int height) { LinearGradient linearGradient = new LinearGradient(width * x0, height * y0, width * x1, height * y1, stopColors, null, Shader.TileMode.CLAMP); return linearGradient; } }); cubicGradientScrimCache.put(cacheKeyHash, paintDrawable); return paintDrawable; }