public void add( double[] vals ) { synchronized( mutex ) { list.add( vals ); } } public void add( double[] vals, int offset, int length ) {
public void add( double[] vals, int offset, int length ) { synchronized( mutex ) { list.add( vals, offset, length ); } }
@Override public TDoubleList getAsDoubleArray() { TDoubleList result = new TDoubleArrayList(size()); for (JsonElement element : array) { result.add(element.getAsDouble()); } return result; }
private void sortMetrics(TObjectDoubleMap<String> metrics, final List<String> activities, final TDoubleList values) { metrics.forEachEntry((s, v) -> { boolean inserted = false; for (int i = 0; i < values.size() && i < limit; i++) { if (v > values.get(i)) { values.insert(i, v); activities.add(i, s); inserted = true; break; } } if (!inserted && values.size() < limit) { activities.add(s); values.add(v); } return true; }); } }
@Override public TDoubleList getAsDoubleArray() { if (data.getDoubleCount() != 0) { TDoubleList result = new TDoubleArrayList(data.getDoubleCount()); for (int i = 0; i < data.getDoubleCount(); ++i) { result.add(data.getDouble(i)); } return result; } else { TDoubleList result = new TDoubleArrayList(data.getFloatCount()); for (int i = 0; i < data.getFloatCount(); ++i) { result.add(data.getFloat(i)); } return result; } }
/** * Calculates Transit center from median of coordinates of all transitStops if graph * has transit. If it doesn't it isn't calculated. (mean walue of min, max latitude and longitudes are used) * * Transit center is saved in center variable * * This speeds up calculation, but problem is that median needs to have all of latitudes/longitudes * in memory, this can become problematic in large installations. It works without a problem on New York State. */ public void calculateTransitCenter() { if (hasTransit) { TDoubleList latitudes = new TDoubleLinkedList(); TDoubleList longitudes = new TDoubleLinkedList(); Median median = new Median(); getVertices().stream() .filter(v -> v instanceof TransitStop) .forEach(v -> { latitudes.add(v.getLat()); longitudes.add(v.getLon()); }); median.setData(latitudes.toArray()); double medianLatitude = median.evaluate(); median = new Median(); median.setData(longitudes.toArray()); double medianLongitude = median.evaluate(); this.center = new Coordinate(medianLongitude, medianLatitude); } }
/** {@inheritDoc} */ public TDoubleList inverseGrep(TDoubleProcedure condition) { TDoubleList ret = new TDoubleLinkedList(); for (TDoubleLink l = head; got(l); l = l.getNext()) { if (!condition.execute(l.getValue())) ret.add(l.getValue()); } return ret; }
/** {@inheritDoc} */ public TDoubleList grep(TDoubleProcedure condition) { TDoubleList ret = new TDoubleLinkedList(); for (TDoubleLink l = head; got(l); l = l.getNext()) { if (condition.execute(l.getValue())) ret.add(l.getValue()); } return ret; }
public void add( double[] vals ) { synchronized( mutex ) { list.add( vals ); } } public void add( double[] vals, int offset, int length ) {
@Override public void add( double[] vals ) { synchronized( mutex ) { list.add( vals ); } } @Override
/** * Returns a list of the sample values in the contained averaged record list. * @return */ public TDoubleList getSamples() { TDoubleList retVal = new TDoubleArrayList(); for(Sample s : averagedRecords) { retVal.add(s.value); } return retVal; }
/** * {@inheritDoc} * * @param <S> the input value, in this case a double * @return a list of one input double */ @Override public <S> TDoubleList getScalars(S d) { TDoubleList retVal = new TDoubleArrayList(); retVal.add((Double)d); return retVal; }
/** * Returns a list of the averages in the contained averaged record list. * @return */ public TDoubleList getMetrics() { TDoubleList retVal = new TDoubleArrayList(); for(Sample s : averagedRecords) { retVal.add(s.score); } return retVal; }
private void refreshWeights() { weights = new TDoubleArrayList(edgeColors.size()); edgeColorList = new ArrayList<>(edgeColors.size()); sumOfWeights = 0; for (EdgeColor edge : edgeColors) { edgeColorList.add(edge); weights.add((sumOfWeights += edge.getWeight())); } }
public synchronized void record(KnownSim ks, SRResult estimate) throws IOException { if (estimate == null || Double.isNaN(estimate.getScore()) || Double.isInfinite(estimate.getScore())) { missing++; } else { actual.add(ks.similarity); estimates.add(estimate.getScore()); sucessful++; } write(ks, estimate == null ? "null" : String.valueOf(estimate.getScore())); }
/** * Get total revenue distance (in meters) for set of trips. * @param trips * @return total trip distance (in meters) */ public double getTotalDistanceForTrips (Collection<Trip> trips) { TDoubleList distances = new TDoubleArrayList(); for (Trip trip : trips) { distances.add(feed.getTripDistance(trip.trip_id, false)); } return distances.sum(); }
public void addStopTime (StopTime st) { stops.add(st.stop_id); pickupTypes.add(st.pickup_type); dropoffTypes.add(st.drop_off_type); // Note, the items listed below are not used in the equality check. arrivalTimes.add(st.arrival_time); departureTimes.add(st.departure_time); timepoints.add(st.timepoint); shapeDistances.add(st.shape_dist_traveled); }
/** {@inheritDoc} */ public TDoubleList inverseGrep(TDoubleProcedure condition) { TDoubleList ret = new TDoubleLinkedList(); for (TDoubleLink l = head; got(l); l = l.getNext()) { if (!condition.execute(l.getValue())) ret.add(l.getValue()); } return ret; }
/** {@inheritDoc} */ public TDoubleList grep(TDoubleProcedure condition) { TDoubleList ret = new TDoubleLinkedList(); for (TDoubleLink l = head; got(l); l = l.getNext()) { if (condition.execute(l.getValue())) ret.add(l.getValue()); } return ret; }
/** {@inheritDoc} */ @Override public TDoubleList grep(TDoubleProcedure condition) { TDoubleList ret = new TDoubleLinkedList(); for (TDoubleLink l = head; got(l); l = l.getNext()) { if (condition.execute(l.getValue())) ret.add(l.getValue()); } return ret; }