List of usage examples for java.lang Double MAX_VALUE
double MAX_VALUE
To view the source code for java.lang Double MAX_VALUE.
Click Source Link
From source file:com.github.cambierr.lorawanpacket.semtech.Stat.java
public Stat(JSONObject _json) throws MalformedPacketException { /**// w w w .j a v a 2s. c om * time */ if (!_json.has("time")) { throw new MalformedPacketException("missing time"); } else { time = _json.getString("time"); } /** * lati */ if (!_json.has("lati")) { lati = Double.MAX_VALUE; } else { lati = _json.getDouble("lati"); } /** * longi */ if (!_json.has("longi")) { lati = Double.MAX_VALUE; } else { longi = _json.getDouble("longi"); } /** * alti */ if (!_json.has("alti")) { alti = Integer.MAX_VALUE; } else { alti = _json.getInt("alti"); } /** * rxnb */ if (!_json.has("rxnb")) { rxnb = Integer.MAX_VALUE; } else { rxnb = _json.getInt("rxnb"); } /** * rxok */ if (!_json.has("rxok")) { rxok = Integer.MAX_VALUE; } else { rxok = _json.getInt("rxok"); } /** * rxfw */ if (!_json.has("rxfw")) { rxfw = Integer.MAX_VALUE; } else { rxfw = _json.getInt("rxfw"); } /** * ackr */ if (!_json.has("ackr")) { ackr = Integer.MAX_VALUE; } else { ackr = _json.getInt("ackr"); } /** * dwnb */ if (!_json.has("dwnb")) { dwnb = Integer.MAX_VALUE; } else { dwnb = _json.getInt("dwnb"); } /** * txnb */ if (!_json.has("txnb")) { txnb = Integer.MAX_VALUE; } else { txnb = _json.getInt("txnb"); } }
From source file:edu.ucsf.valelab.saim.calculations.SaimFunctionWithBounds.java
/** * Calculates the field intensity at a given angle, given the parameters * A, B, and height./* w w w .j a va 2 s . c om*/ * @param x - angle in radians * @param parameters - array of 3 values: * A - scaling parameter * B - offset parameter, accounting for background * h - height in nm * @return - Calculated field intensity */ @Override public double value(double x, double... parameters) { if (parameters.length != 3) throw new DimensionMismatchException(parameters.length, 3); sd_.A_ = parameters[0]; sd_.B_ = parameters[1]; angle_ = x; if (parameters[0] < 0 || parameters[1] < 0 || parameters[2] < 0) { return Double.MAX_VALUE; } return value(parameters[2]); }
From source file:classif.kmeans.KMeansSymbolicSequence.java
public void cluster() { centers = new Sequence[nbClusters]; affectation = new ArrayList[nbClusters]; // pickup centers int[] selected = randGen.nextPermutation(data.size(), nbClusters); for (int i = 0; i < selected.length; i++) { centers[i] = data.get(selected[i]); }// w w w.j a va2 s. c o m // for each iteration i for (int i = 0; i < 15; i++) { // init for (int k = 0; k < affectation.length; k++) { affectation[k] = new ArrayList<Sequence>(); } // for each data point j for (int j = 0; j < data.size(); j++) { double minDist = Double.MAX_VALUE; // for each cluster k for (int k = 0; k < centers.length; k++) { // distance between cluster k and data point j double currentDist = centers[k].distance(data.get(j)); if (currentDist < minDist) { clusterMap[j] = k; minDist = currentDist; } } // affect data point j to cluster affected to j affectation[clusterMap[j]].add(data.get(j)); } // redefine for (int j = 0; j < nbClusters; j++) { if (affectation[j].size() == 0) { centers[j] = null; } else { centers[j] = Sequences.mean(affectation[j].toArray(new Sequence[0])); } } } }
From source file:net.sf.dsp4j.octave.packages.signal_1_2_0.Cheb2Ord.java
private void calcCheb2Ord(double[] Wp, double[] Ws, double Rp, double Rs) { double T = 2; // returned frequency is the same as the input frequency Wc = Arrays.copyOf(Ws, Ws.length); // warp the target frequencies according to the bilinear transform for (int i = 0; i < Wp.length; i++) { Ws[i] = 2.0 / T * Math.tan(Math.PI * Ws[i] / T); Wp[i] = 2.0 / T * Math.tan(Math.PI * Wp[i] / T); }//from w w w.j a va 2s . c o m double Wa; if (Wp[0] < Ws[0]) { // low pass if (Wp.length == 1) { Wa = Wp[0] / Ws[0]; } else { // band reject throw new RuntimeException("band reject is not implement yet."); } } else { // if high pass, reverse the sense of the test if (Wp.length == 1) { Wa = Ws[0] / Wp[0]; } else { // band pass Wa = Double.MAX_VALUE; for (int i = 0; i < Wp.length; i++) { Wa = Math.min(Wa, Math.abs((Math.pow(Wp[i], 2) - Ws[0] * Ws[1]) / (Wp[i] * (Ws[0] - Ws[1])))); } } } // compute minimum n which satisfies all band edge conditions final double stop_atten = Math.pow(10, Math.abs(Rs) / 10.0); final double pass_atten = Math.pow(10, Math.abs(Rp) / 10.0); n = (int) Math.ceil( FastMath.acosh(Math.sqrt((stop_atten - 1.0) / (pass_atten - 1.0))) / FastMath.acosh(1.0 / Wa)); }
From source file:net.sf.dsp4j.octave.packages.signal_1_2_0.Cheb1Ord.java
private void calcCheb1Ord(double[] Wp, double[] Ws, double Rp, double Rs) { double T = 2; // returned frequency is the same as the input frequency Wc = Arrays.copyOf(Wp, Wp.length); // warp the target frequencies according to the bilinear transform for (int i = 0; i < Wp.length; i++) { Ws[i] = 2.0 / T * Math.tan(Math.PI * Ws[i] / T); Wp[i] = 2.0 / T * Math.tan(Math.PI * Wp[i] / T); }//from w ww.j a va 2 s.co m double Wa; if (Wp[0] < Ws[0]) // low pass { if (Wp.length == 1) { Wa = Ws[0] / Wp[0]; } else { // band reject throw new RuntimeException("band reject is not implement yet."); } } else { // if high pass, reverse the sense of the test if (Wp.length == 1) { Wa = Wp[0] / Ws[0]; } else { // band pass Wa = Double.MAX_VALUE; for (int i = 0; i < Wp.length; i++) { Wa = Math.min(Wa, Math.abs((Math.pow(Ws[i], 2) - Wp[0] * Wp[1]) / (Ws[i] * (Wp[0] - Wp[1])))); } } } // compute minimum n which satisfies all band edge conditions final double stop_atten = Math.pow(10, Math.abs(Rs) / 10.0); final double pass_atten = Math.pow(10, Math.abs(Rp) / 10.0); n = (int) Math .ceil(FastMath.acosh(Math.sqrt((stop_atten - 1.0) / (pass_atten - 1.0))) / FastMath.acosh(Wa)); }
From source file:eu.vital.orchestrator.rest.EvaluationRESTService.java
@POST @Path("/latest") public Response executeLatestScenario(JsonNode input) throws Exception { String dmsUrl = "https://local.vital-iot.eu:8443/vital-core-dms"; // 1. Get List of sensors from DMS observing AvailableBikes Client dmsClient = ClientBuilder.newClient(); WebTarget dmsTarget = dmsClient.target(dmsUrl).path("querySensor").queryParam("encodeKeys", "false"); ObjectNode sensorQuery = objectMapper.createObjectNode(); sensorQuery.put("http://purl\\u002eoclc\\u002eorg/NET/ssnx/ssn#observes.@type", "http://vital-iot.eu/ontology/ns/Speed"); ArrayNode sensorList = dmsTarget.request(MediaType.APPLICATION_JSON_TYPE).post(Entity.json(sensorQuery), ArrayNode.class); // 2. Find the nearest sensor double minDistance = Double.MAX_VALUE; JsonNode nearestSensor = null;/*from w w w . j a va 2s. c om*/ for (int i = 0; i < sensorList.size(); i++) { JsonNode sensor = sensorList.get(i); // Calculate Distance: double tmp = distance(input.get("lat").asDouble(), input.get("lng").asDouble(), sensor.get("hasLastKnownLocation").get("geo:lat").asDouble(), sensor.get("hasLastKnownLocation").has("geo:long") ? sensor.get("hasLastKnownLocation").get("geo:long").asDouble() : sensor.get("hasLastKnownLocation").get("geo:lon").asDouble()); if (tmp < minDistance) { minDistance = tmp; nearestSensor = sensor; } } // 3. Find the System of the Sensor dmsTarget = dmsClient.target(dmsUrl).path("querySystem").queryParam("encodeKeys", "false"); ObjectNode systemQuery = objectMapper.createObjectNode(); systemQuery.put("http://vital-iot\\u002eeu/ontology/ns/managesSensor.@id", nearestSensor.get("id").asText()); ArrayNode systemList = dmsTarget.request(MediaType.APPLICATION_JSON_TYPE).post(Entity.json(systemQuery), ArrayNode.class); JsonNode system = systemList.get(0); // 4. Find the Observation Service of the System dmsTarget = dmsClient.target(dmsUrl).path("queryService").queryParam("encodeKeys", "false"); ObjectNode serviceAndQuery = objectMapper.createObjectNode(); ArrayNode serviceAndParameters = objectMapper.createArrayNode(); serviceAndQuery.put("$and", serviceAndParameters); ObjectNode serviceIdQuery = objectMapper.createObjectNode(); ObjectNode serviceInQuery = objectMapper.createObjectNode(); serviceInQuery.put("$in", system.get("services")); serviceIdQuery.put("@id", serviceInQuery); serviceAndParameters.add(serviceIdQuery); ObjectNode serviceTypeQuery = objectMapper.createObjectNode(); serviceTypeQuery.put("@type", "http://vital-iot.eu/ontology/ns/ObservationService"); serviceAndParameters.add(serviceTypeQuery); ArrayNode serviceList = dmsTarget.request(MediaType.APPLICATION_JSON_TYPE) .post(Entity.json(serviceAndQuery), ArrayNode.class); JsonNode observationService = serviceList.get(0); // 5. Call GetObservation operation of the service String operationUrl = observationService.get("operations").get("hrest:hasAddress").asText(); Client systemClient = ClientBuilder.newClient(); WebTarget systemTarget = systemClient.target(operationUrl); ObjectNode operationInput = objectMapper.createObjectNode(); ArrayNode sensorsArray = objectMapper.createArrayNode(); sensorsArray.add(nearestSensor.get("id").asText()); operationInput.put("sensor", sensorsArray); operationInput.put("property", "http://vital-iot.eu/ontology/ns/Speed"); ArrayNode observationList = systemTarget.request(MediaType.APPLICATION_JSON_TYPE) .post(Entity.json(operationInput), ArrayNode.class); JsonNode latestObservation = observationList.get(0); // 6. Parse Result and return response ObjectNode result = objectMapper.createObjectNode(); result.put("measurementValue", latestObservation.get("ssn:observationResult").get("ssn:hasValue").get("value")); result.put("measurementDate", latestObservation.get("ssn:observationResultTime").get("time:inXSDDateTime")); return Response.ok(result).build(); }
From source file:com.github.lynxdb.server.core.aggregators.Max.java
@Override public TimeSerie downsample(TimeSerie _serie, long _period) { return doDownsampling(_serie, _period, new Reducer() { double max; @Override/*from ww w . j av a 2 s . c o m*/ public void update(Entry _entry) { if (_entry.getValue() > max) { max = _entry.getValue(); } } @Override public double result() { return max; } @Override public void reset() { max = -Double.MAX_VALUE; } }); }
From source file:classif.pukmeans.KMeansCachedSymbolicSequence.java
public void cluster() { Sequence[] initialCenters = new Sequence[nbClusters]; affectation = new ArrayList[nbClusters]; // init/*from w ww. j ava2 s .c o m*/ for (int k = 0; k < affectation.length; k++) { affectation[k] = new ArrayList<Integer>(); } // pickup centers int[] selected = randGen.nextPermutation(data.size(), nbClusters); for (int i = 0; i < selected.length; i++) { initialCenters[i] = data.get(selected[i]); } wcss = 0.0; // first affectation for (int j = 0; j < data.size(); j++) { double minDist = Double.MAX_VALUE; int bestK = -1; // for each cluster k for (int k = 0; k < initialCenters.length; k++) { // distance between cluster k and data point j double currentDist = initialCenters[k].distance(data.get(j)); if (currentDist < minDist) { bestK = k; minDist = currentDist; } } wcss += minDist * minDist; // affect data point j to cluster affected to j affectation[bestK].add(j); } // for each iteration i for (int i = 0; i < 15; i++) { ArrayList<Integer>[] newAffectation = new ArrayList[nbClusters]; // init for (int k = 0; k < newAffectation.length; k++) { newAffectation[k] = new ArrayList<Integer>(); } wcss = 0.0; // reassign element to cluster for (int j = 0; j < data.size(); j++) { int bestK = -1; double bestDist = Double.POSITIVE_INFINITY; // for each cluster k for (int k = 0; k < nbClusters; k++) { if (affectation[k].size() == 0) continue; double distToK = 0.0; for (Integer elIndex : affectation[k]) { double tmpDist = distances[j][elIndex]; distToK += tmpDist;//TODO squared?? } distToK /= affectation[k].size(); if (distToK < bestDist) { bestDist = distToK; bestK = k; } } wcss += bestDist * bestDist; newAffectation[bestK].add(j); } affectation = newAffectation; } //find prototypes for classifier centers = new Sequence[nbClusters]; for (int k = 0; k < nbClusters; k++) { if (affectation[k].size() == 0) { centers[k] = null; } else { int medoidIndex = Sequences.medoidIndex(affectation[k], distances); Sequence medoid = data.get(medoidIndex); Sequence[] sequenceTab = new Sequence[affectation[k].size()]; for (int i = 0; i < sequenceTab.length; i++) { sequenceTab[i] = data.get(affectation[k].get(i)); } centers[k] = Sequences.meanWithMedoid(medoid, sequenceTab); } } }
From source file:com.github.lynxdb.server.core.aggregators.MimMin.java
@Override public TimeSerie downsample(TimeSerie _serie, long _period) { return doDownsampling(_serie, _period, new Reducer() { double min; @Override//from w w w.j av a 2 s. c o m public void update(Entry _entry) { if (_entry.getValue() < min) { min = _entry.getValue(); } } @Override public double result() { return min; } @Override public void reset() { min = Double.MAX_VALUE; } }); }
From source file:com.cidre.algorithms.CidreMath.java
public static double min(double[][] a) { double min = Double.MAX_VALUE; for (int i = 0; i < a.length; i++) { for (int j = 0; j < a[i].length; j++) { if (a[i][j] < min) { min = a[i][j];/*w w w . ja v a 2 s .co m*/ } } } return min; }