当前位置: 首页>>代码示例>>Java>>正文


Java TDoubleList.add方法代码示例

本文整理汇总了Java中gnu.trove.list.TDoubleList.add方法的典型用法代码示例。如果您正苦于以下问题:Java TDoubleList.add方法的具体用法?Java TDoubleList.add怎么用?Java TDoubleList.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gnu.trove.list.TDoubleList的用法示例。


在下文中一共展示了TDoubleList.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAverageSpeedForTrips

import gnu.trove.list.TDoubleList; //导入方法依赖的package包/类
/**
 * Get average speed for set of trips that begin within the time window in meters per second.
 * @param trips
 * @param from
 * @param to
 * @return avg. speed (meters per second)
 */
public double getAverageSpeedForTrips (Collection<Trip> trips, LocalTime from, LocalTime to) {
    TDoubleList speeds = new TDoubleArrayList();

    for (Trip trip : trips) {
        StopTime firstStopTime = feed.stop_times.ceilingEntry(Fun.t2(trip.trip_id, null)).getValue();
        LocalTime tripBeginTime = LocalTime.ofSecondOfDay(firstStopTime.departure_time % 86399); // convert 24hr+ seconds to 0 - 86399

        // skip trip if begin time is before or after specified time period
        if (tripBeginTime.isAfter(to) || tripBeginTime.isBefore(from)) {
            continue;
        }
        // TODO: swap straight lines for actual geometry?
        double speed = feed.getTripSpeed(trip.trip_id, true);

        if (!Double.isNaN(speed)) {
            speeds.add(speed);
        }
    }

    if (speeds.isEmpty()) return -1;

    return speeds.sum() / speeds.size();
}
 
开发者ID:conveyal,项目名称:gtfs-lib,代码行数:31,代码来源:PatternStats.java

示例2: getScalars

import gnu.trove.list.TDoubleList; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public <S> TDoubleList getScalars(S input) {
    String inputCasted = (String)input;
    int index = 0;
    TDoubleList result = new TDoubleArrayList();
    if (inputCasted == null || inputCasted.isEmpty()) {
        result.add(0);
        return result;
    }
    if (!sdrByCategory.containsKey(input)) {
        if (isEncoderLearningEnabled()) {
            index = sdrByCategory.size();
            addCategory(inputCasted);
        }
    } else {
        index = sdrByCategory.getIndexByCategory(inputCasted);
    }
    result.add(index);
    return result;
}
 
开发者ID:numenta,项目名称:htm.java,代码行数:24,代码来源:SDRCategoryEncoder.java

示例3: compute

import gnu.trove.list.TDoubleList; //导入方法依赖的package包/类
/**
 * Internal method which does actual calculation
 * 
 * @param calc              Re-used calculation object
 * @param slidingWindow     a list of previous values to use in the computation that
 *                          will be modified and returned
 * @param total             total the sum of the values in the  slidingWindow to be used in the
 *                          calculation of the moving average
 * @param newVal            newVal a new number to compute the new windowed average
 * @param windowSize        windowSize how many values to use in the moving window
 * @return
 */
private static Calculation compute(
    Calculation calc, TDoubleList slidingWindow, double total, double newVal, int windowSize) {
    
    if(slidingWindow == null) {
        throw new IllegalArgumentException("slidingWindow cannot be null.");
    }
    
    if(slidingWindow.size() == windowSize) {
        total -= slidingWindow.removeAt(0);
    }
    slidingWindow.add(newVal);
    total += newVal;
    
    if(calc == null) {
        return new Calculation(slidingWindow, total / (double)slidingWindow.size(), total);
    }
    
    return copyInto(calc, slidingWindow, total / (double)slidingWindow.size(), total);
}
 
开发者ID:numenta,项目名称:htm.java,代码行数:32,代码来源:MovingAverage.java

示例4: grep

import gnu.trove.list.TDoubleList; //导入方法依赖的package包/类
/** {@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;
}
 
开发者ID:JianpingZeng,项目名称:xcc,代码行数:10,代码来源:TDoubleLinkedList.java

示例5: inverseGrep

import gnu.trove.list.TDoubleList; //导入方法依赖的package包/类
/** {@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;
}
 
开发者ID:JianpingZeng,项目名称:xcc,代码行数:10,代码来源:TDoubleLinkedList.java

示例6: grep

import gnu.trove.list.TDoubleList; //导入方法依赖的package包/类
/** {@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;
}
 
开发者ID:palantir,项目名称:trove-3.0.3,代码行数:11,代码来源:TDoubleLinkedList.java

示例7: inverseGrep

import gnu.trove.list.TDoubleList; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
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;
}
 
开发者ID:palantir,项目名称:trove-3.0.3,代码行数:11,代码来源:TDoubleLinkedList.java

示例8: getTotalDistanceForTrips

import gnu.trove.list.TDoubleList; //导入方法依赖的package包/类
/**
 * 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();
}
 
开发者ID:conveyal,项目名称:gtfs-lib,代码行数:14,代码来源:PatternStats.java

示例9: getScalars

import gnu.trove.list.TDoubleList; //导入方法依赖的package包/类
/**
 * {@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;
}
 
开发者ID:numenta,项目名称:htm.java,代码行数:13,代码来源:ScalarEncoder.java

示例10: closenessScores

import gnu.trove.list.TDoubleList; //导入方法依赖的package包/类
public TDoubleList closenessScores(TDoubleList expValues, TDoubleList actValues, boolean fractional) {
	TDoubleList retVal = new TDoubleArrayList();

	//Fallback closenss is a percentage match
	List<EncoderTuple> encoders = getEncoders(this);
	if(encoders == null || encoders.size() < 1) {
		double err = Math.abs(expValues.get(0) - actValues.get(0));
		double closeness = -1;
		if(fractional) {
			double denom = Math.max(expValues.get(0), actValues.get(0));
			if(denom == 0) {
				denom = 1.0;
			}

			closeness = 1.0 - err/denom;
			if(closeness < 0) {
				closeness = 0;
			}
		}else{
			closeness = err;
		}

		retVal.add(closeness);
		return retVal;
	}

	int scalarIdx = 0;
	for(EncoderTuple res : getEncoders(this)) {
		TDoubleList values = res.getEncoder().closenessScores(
			expValues.subList(scalarIdx, expValues.size()), actValues.subList(scalarIdx, actValues.size()), fractional);

		scalarIdx += values.size();
		retVal.addAll(values);
	}

	return retVal;
}
 
开发者ID:numenta,项目名称:htm.java,代码行数:38,代码来源:Encoder.java

示例11: closenessScores

import gnu.trove.list.TDoubleList; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public TDoubleList closenessScores(TDoubleList expValues, TDoubleList actValues, boolean fractional) {
	TDoubleList retVal = new TDoubleArrayList();

	double expValue, actValue;
	if (expValues.get(0) > 0) {
		expValue = Math.log10(expValues.get(0));
	} else {
		expValue = minScaledValue;
	}
	if (actValues.get(0) > 0) {
		actValue = Math.log10(actValues.get(0));
	} else {
		actValue = minScaledValue;
	}

	double closeness;
	if (fractional) {
		double err = Math.abs(expValue - actValue);
		double pctErr = err / (maxScaledValue - minScaledValue);
		pctErr = Math.min(1.0,  pctErr);
		closeness = 1.0 - pctErr;
	} else {
		closeness = Math.abs(expValue - actValue);;
	}

	retVal.add(closeness);
	return retVal;
}
 
开发者ID:numenta,项目名称:htm.java,代码行数:33,代码来源:LogEncoder.java

示例12: getMetrics

import gnu.trove.list.TDoubleList; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:numenta,项目名称:htm.java,代码行数:13,代码来源:Anomaly.java

示例13: getSamples

import gnu.trove.list.TDoubleList; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:numenta,项目名称:htm.java,代码行数:13,代码来源:Anomaly.java

示例14: testCopy

import gnu.trove.list.TDoubleList; //导入方法依赖的package包/类
@SuppressWarnings("serial")
@Test
public void testCopy() {
    double[] likelihoods = new double[] { 0.2, 0.3 };

    Sample s = new Sample(new DateTime(), 0.1, 0.1);
    List<Sample> samples = new ArrayList<>();
    samples.add(s);
    TDoubleList d = new TDoubleArrayList();
    d.add(0.5);
    double total = 0.4;
    AveragedAnomalyRecordList avges = (
            new Anomaly() {
                @Override
                public double compute(int[] activeColumns, int[] predictedColumns, double inputValue, long timestamp) {
                    return 0;
                }
            }
    ).new AveragedAnomalyRecordList(samples, d, total);

    Statistic stat = new Statistic(0.1, 0.1, 0.1);
    MovingAverage ma = new MovingAverage(new TDoubleArrayList(), 1);
    AnomalyParams params = new AnomalyParams(new String[] { Anomaly.KEY_DIST, Anomaly.KEY_MVG_AVG, Anomaly.KEY_HIST_LIKE}, stat, ma, likelihoods);

    // Test equality
    AnomalyLikelihoodMetrics metrics = new AnomalyLikelihoodMetrics(likelihoods, avges, params);
    AnomalyLikelihoodMetrics metrics2 = metrics.copy();
    assertEquals(metrics, metrics2);
}
 
开发者ID:numenta,项目名称:htm.java,代码行数:30,代码来源:AnomalyLikelihoodMetricsTest.java

示例15: benchmarkConceptSimilarity

import gnu.trove.list.TDoubleList; //导入方法依赖的package包/类
public void benchmarkConceptSimilarity()   throws ConfigurationException, DaoException {
    TDoubleList list = new TDoubleArrayList();
    Concept x = concepts.iterator().next();
    System.out.println("Start ConceptSimilarity");
    long start = System.currentTimeMillis();
    for (Concept y : concepts) {
        list.add(cSim.similarity(x, y));
    }
    long end = System.currentTimeMillis();
    System.out.println("Ellapsed time: " + (end-start));
    System.out.println("Unit time: " + (end-start)/SIZE);
}
 
开发者ID:shilad,项目名称:sem-tag,代码行数:13,代码来源:Benchmark.java


注:本文中的gnu.trove.list.TDoubleList.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。