List of usage examples for java.lang Math pow
@HotSpotIntrinsicCandidate public static double pow(double a, double b)
From source file:com.google.location.lbs.gnss.gps.pseudorange.EcefToTopocentricConverter.java
/** * Transformation of {@code inputVectorMeters} with origin at {@code originECEFMeters} into * topocentric coordinate system. The result is {@code TopocentricAEDValues} containing azimuth * from north +ve clockwise, radians; elevation angle, radians; distance, vector length meters * * <p>Source: http://www.navipedia.net/index.php/Transformations_between_ECEF_and_ENU_coordinates * http://kom.aau.dk/~borre/life-l99/topocent.m * *//*w w w . j a v a 2 s. c o m*/ public static TopocentricAEDValues convertCartesianToTopocentericRadMeters(final double[] originECEFMeters, final double[] inputVectorMeters) { GeodeticLlaValues latLngAlt = Ecef2LlaConverter.convertECEFToLLACloseForm(originECEFMeters[0], originECEFMeters[1], originECEFMeters[2]); RealMatrix rotationMatrix = Ecef2EnuConverter .getRotationMatrix(latLngAlt.latitudeRadians, latLngAlt.longitudeRadians).transpose(); double[] eastNorthUpVectorMeters = GpsMathOperations .matrixByColVectMultiplication(rotationMatrix.transpose().getData(), inputVectorMeters); double eastMeters = eastNorthUpVectorMeters[EAST_IDX]; double northMeters = eastNorthUpVectorMeters[NORTH_IDX]; double upMeters = eastNorthUpVectorMeters[UP_IDX]; // calculate azimuth, elevation and height from the ENU values double horizontalDistanceMeters = Math.hypot(eastMeters, northMeters); double azimuthRadians; double elevationRadians; if (horizontalDistanceMeters < MIN_DISTANCE_MAGNITUDE_METERS) { elevationRadians = Math.PI / 2.0; azimuthRadians = 0; } else { elevationRadians = Math.atan2(upMeters, horizontalDistanceMeters); azimuthRadians = Math.atan2(eastMeters, northMeters); } if (azimuthRadians < 0) { azimuthRadians += 2 * Math.PI; } double distanceMeters = Math.sqrt(Math.pow(inputVectorMeters[0], 2) + Math.pow(inputVectorMeters[1], 2) + Math.pow(inputVectorMeters[2], 2)); return new TopocentricAEDValues(elevationRadians, azimuthRadians, distanceMeters); }
From source file:edu.uniandes.ecos.ase.calculo.CalculoSimpsonRule.java
@Override public double coeficienteTres(double dof) { double coeficienteTres = 0; try {//from www . j av a 2s .c om coeficienteTres = (calcularGamma((dof + 1) / 2)) / (((Math.pow(dof * Math.PI, 0.5))) * calcularGamma(dof / 2)); } catch (Exception e) { System.out.println("Error calculando el coeficiente tres: " + e.getMessage()); } return coeficienteTres; }
From source file:electrical_parameters.Admittance.java
public Admittance(RealMatrix Dik, RealMatrix Dik_mirror, double[] hx2, ArrayList<elpam_input_conductor> cnd_list, double krok, // m int n_zv, // - int fv, int gw) { this.r_cnd = new double[cnd_list.size()]; if (cnd_list.get(0).isBundle()) { double rho = krok / (2 * Math.sin(Math.PI / n_zv)); for (int i = 0; i < cnd_list.size(); i++) { this.r_cnd[i] = Math.pow(n_zv * (cnd_list.get(i).getD() / 2) * Math.pow(rho, n_zv - 1), (double) 1 / n_zv); }// w w w .j a va2 s . co m } else { for (int i = 0; i < cnd_list.size(); i++) { this.r_cnd[i] = cnd_list.get(i).getD() / 2; } } this.fv = fv; this.gw = gw; this.f = constants.getFrequency(); this.Dik = Dik; this.Dik_mirror = Dik_mirror; this.hx2 = hx2; this.P = new Array2DRowRealMatrix(fv + gw, fv + gw); this.P_red = new Array2DRowRealMatrix(fv, fv); this.C = new Array2DRowRealMatrix(fv, fv); this.B = new Array2DRowRealMatrix(fv, fv); this.Y = new ComplexMatrix(fv, fv); this.C_symm = new Array2DRowRealMatrix(fv, fv); this.B_symm = new Array2DRowRealMatrix(fv, fv); this.Y_symm = new ComplexMatrix(fv, fv); this.omega = (double) 2 * Math.PI * this.f; this.cnst = (double) 1 / (8.854187e-9 * 1 * 2 * Math.PI); }
From source file:com.xy.inc.service.impl.POIServiceImpl.java
@Override public List<POI> buscarPOISProximos(Integer coordenadaX, Integer coordenadaY, Integer distMax) throws ServiceException { try {//from www . ja v a 2 s .c o m List<POI> poiList = new ArrayList<>(); for (POI poi : poiRepository.findAll()) { if (Math.sqrt(Math.pow(coordenadaX - poi.getCoordenadaX(), 2) + Math.pow(coordenadaY - poi.getCoordenadaY(), 2)) <= 10) { poiList.add(poi); } } return poiList; } catch (Exception e) { throw new ServiceException("No foi possivel buscar os POIs proximos"); } }
From source file:com.itemanalysis.psychometrics.kernel.LocalLinearRegression.java
public double[] evaluate(double[] x, double[] y) throws DimensionMismatchException { if (x.length != y.length) throw new DimensionMismatchException(x.length, y.length); n = x.length;/*from www .j av a 2 s. c o m*/ double[] yprime = new double[n]; double d = 0; double kernD = 0; double s0 = 0, s1 = 0, s2 = 0; for (int j = 0; j < numPoints; j++) { for (int i = 0; i < n; i++) { d = x[i] - points[j]; kernD = kernel.value(d / bandwidth); s0 += kernD; s1 += d * kernD; s2 += d * d * kernD; } s0 /= n; s1 /= n; s2 /= n; for (int i = 0; i < n; i++) { yprime[j] += ((s2 - s1 * d) * kernD * y[i]) / (s2 * s0 - Math.pow(s1, 2)); } yprime[j] /= n; } return yprime; }
From source file:beans.NTPClient.java
/** * Process <code>TimeInfo</code> object and print its details. * //from www . j ava 2 s .c o m * @param info * <code>TimeInfo</code> object. */ public static void processResponse(TimeInfo info) { NtpV3Packet message = info.getMessage(); int stratum = message.getStratum(); String refType; if (stratum <= 0) { refType = "(Unspecified or Unavailable)"; } else if (stratum == 1) { refType = "(Primary Reference; e.g., GPS)"; // GPS, radio clock, etc. } else { refType = "(Secondary Reference; e.g. via NTP or SNTP)"; } // stratum should be 0..15... System.out.println(" Stratum: " + stratum + " " + refType); int version = message.getVersion(); int li = message.getLeapIndicator(); System.out.println(" leap=" + li + ", version=" + version + ", precision=" + message.getPrecision()); System.out.println(" mode: " + message.getModeName() + " (" + message.getMode() + ")"); int poll = message.getPoll(); // poll value typically btwn MINPOLL (4) and MAXPOLL (14) System.out.println( " poll: " + (poll <= 0 ? 1 : (int) Math.pow(2, poll)) + " seconds" + " (2 ** " + poll + ")"); double disp = message.getRootDispersionInMillisDouble(); System.out.println(" rootdelay=" + numberFormat.format(message.getRootDelayInMillisDouble()) + ", rootdispersion(ms): " + numberFormat.format(disp)); int refId = message.getReferenceId(); String refAddr = NtpUtils.getHostAddress(refId); String refName = null; if (refId != 0) { if (refAddr.equals("127.127.1.0")) { refName = "LOCAL"; // This is the ref address for the Local Clock } else if (stratum >= 2) { // If reference id has 127.127 prefix then it uses its own reference // clock // defined in the form 127.127.clock-type.unit-num (e.g. 127.127.8.0 // mode 5 // for GENERIC DCF77 AM; see refclock.htm from the NTP software // distribution. if (!refAddr.startsWith("127.127")) { try { InetAddress addr = InetAddress.getByName(refAddr); String name = addr.getHostName(); if (name != null && !name.equals(refAddr)) { refName = name; } } catch (UnknownHostException e) { // some stratum-2 servers sync to ref clock device but fudge stratum // level higher... (e.g. 2) // ref not valid host maybe it's a reference clock name? // otherwise just show the ref IP address. refName = NtpUtils.getReferenceClock(message); } } } else if (version >= 3 && (stratum == 0 || stratum == 1)) { refName = NtpUtils.getReferenceClock(message); // refname usually have at least 3 characters (e.g. GPS, WWV, LCL, etc.) } // otherwise give up on naming the beast... } if (refName != null && refName.length() > 1) { refAddr += " (" + refName + ")"; } System.out.println(" Reference Identifier:\t" + refAddr); TimeStamp refNtpTime = message.getReferenceTimeStamp(); System.out.println(" Reference Timestamp:\t" + refNtpTime + " " + refNtpTime.toDateString()); // Originate Time is time request sent by client (t1) TimeStamp origNtpTime = message.getOriginateTimeStamp(); System.out.println(" Originate Timestamp:\t" + origNtpTime + " " + origNtpTime.toDateString()); long destTime = info.getReturnTime(); // Receive Time is time request received by server (t2) TimeStamp rcvNtpTime = message.getReceiveTimeStamp(); System.out.println(" Receive Timestamp:\t" + rcvNtpTime + " " + rcvNtpTime.toDateString()); // Transmit time is time reply sent by server (t3) TimeStamp xmitNtpTime = message.getTransmitTimeStamp(); System.out.println(" Transmit Timestamp:\t" + xmitNtpTime + " " + xmitNtpTime.toDateString()); // Destination time is time reply received by client (t4) TimeStamp destNtpTime = TimeStamp.getNtpTime(destTime); System.out.println(" Destination Timestamp:\t" + destNtpTime + " " + destNtpTime.toDateString()); info.computeDetails(); // compute offset/delay if not already done Long offsetValue = info.getOffset(); Long delayValue = info.getDelay(); String delay = (delayValue == null) ? "N/A" : delayValue.toString(); String offset = (offsetValue == null) ? "N/A" : offsetValue.toString(); System.out.println(" Roundtrip delay(ms)=" + delay + ", clock offset(ms)=" + offset); // offset // in // ms }
From source file:jsat.distributions.empirical.MyKernelDensityEstimator.java
public static double BandwithGuassEstimate(Vec X) { if (X.length() == 1) { return 1; } else if (X.standardDeviation() == 0) { return 1.06 * Math.pow(X.length(), -1.0 / 5.0); }//from ww w .j av a2s . c om return 1.06 * X.standardDeviation() * Math.pow(X.length(), -1.0 / 5.0); }
From source file:com.alvermont.terraj.stargen.AccreteUtils.java
/** * Get the stellar dust limit for a particular mass * * @param stellMassRatio The stellar mass ratio * @return The dust limit for the specified mass *///from ww w . j a va2s .c o m public static double getStellarDustLimit(double stellMassRatio) { return (200.0 * Math.pow(stellMassRatio, (1.0 / 3.0))); }
From source file:com.opengamma.analytics.financial.model.option.pricing.analytic.formula.CEVPriceFunction.java
@Override public Function1D<CEVFunctionData, Double> getPriceFunction(final EuropeanVanillaOption option) { final double k = option.getStrike(); final double t = option.getTimeToExpiry(); final boolean isCall = option.isCall(); return new Function1D<CEVFunctionData, Double>() { @SuppressWarnings("synthetic-access") @Override// www. j a v a2s. c o m public Double evaluate(final CEVFunctionData data) { Validate.notNull(data, "data"); final double forward = data.getForward(); final double numeraire = data.getNumeraire(); final double sigma = data.getVolatility(); final double beta = data.getBeta(); if (beta == 1.0) { final Function1D<BlackFunctionData, Double> blackFormula = BLACK_PRICE_FUNCTION .getPriceFunction(option); return blackFormula.evaluate(new BlackFunctionData(forward, numeraire, sigma)); } if (beta == 0.0) { final Function1D<NormalFunctionData, Double> normalFormula = NORMAL_PRICE_FUNCTION .getPriceFunction(option); return normalFormula.evaluate(new NormalFunctionData(forward, numeraire, sigma)); } final double b = 1.0 / (1 - beta); final double x = b * b / sigma / sigma / t; final double a = Math.pow(k, 2 * (1 - beta)) * x; final double c = Math.pow(forward, 2 * (1 - beta)) * x; if (beta < 1) { final NonCentralChiSquaredDistribution chiSq1 = new NonCentralChiSquaredDistribution(b + 2, c); final NonCentralChiSquaredDistribution chiSq2 = new NonCentralChiSquaredDistribution(b, a); if (isCall) { return numeraire * (forward * (1 - chiSq1.getCDF(a)) - k * chiSq2.getCDF(c)); } return numeraire * (k * (1 - chiSq2.getCDF(c)) - forward * chiSq1.getCDF(a)); } final NonCentralChiSquaredDistribution chiSq1 = new NonCentralChiSquaredDistribution(-b, a); final NonCentralChiSquaredDistribution chiSq2 = new NonCentralChiSquaredDistribution(2 - b, c); if (isCall) { return numeraire * (forward * (1 - chiSq1.getCDF(c)) - k * chiSq2.getCDF(a)); } return numeraire * (k * (1 - chiSq2.getCDF(a)) - forward * chiSq1.getCDF(c)); } }; }
From source file:com.caseystella.analytics.outlier.batch.rpca.RPCA.java
private void computeRSVD() { double mu = X.getColumnDimension() * X.getRowDimension() / (4 * l1norm(X.getData())); double objPrev = 0.5 * Math.pow(X.getFrobeniusNorm(), 2); double obj = objPrev; double tol = 1e-8 * objPrev; double diff = 2 * tol; int iter = 0; while (diff > tol && iter < MAX_ITERS) { double nuclearNorm = computeS(mu); double l1Norm = computeL(mu); double l2Norm = computeE(); obj = computeObjective(nuclearNorm, l1Norm, l2Norm); diff = Math.abs(objPrev - obj); objPrev = obj;/* www .j a v a 2 s.c o m*/ mu = computeDynamicMu(); iter = iter + 1; } }