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


Java TDoubleList类代码示例

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


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

示例1: subList

import gnu.trove.list.TDoubleList; //导入依赖的package包/类
/** {@inheritDoc} */
  public TDoubleList subList( int begin, int end ) {
  	if ( end < begin ) {
	throw new IllegalArgumentException( "end index " + end +
		" greater than begin index " + begin );
}
if ( begin < 0 ) {
	throw new IndexOutOfBoundsException( "begin index can not be < 0" );
}
if ( end > _data.length ) {
	throw new IndexOutOfBoundsException( "end index < " + _data.length );
}
      TDoubleArrayList list = new TDoubleArrayList( end - begin );
      for ( int i = begin; i < end; i++ ) {
      	list.add( _data[ i ] );
      }
      return list;
  }
 
开发者ID:JianpingZeng,项目名称:xcc,代码行数:19,代码来源:TDoubleArrayList.java

示例2: subList

import gnu.trove.list.TDoubleList; //导入依赖的package包/类
/** {@inheritDoc} */
public TDoubleList subList(int begin, int end) {
    if (end < begin) {
        throw new IllegalArgumentException("begin index " + begin +
                " greater than end index " + end);
    }
    if (size < begin) {
        throw new IllegalArgumentException("begin index " + begin +
                " greater than last index " + size);
    }
    if (begin < 0) {
        throw new IndexOutOfBoundsException("begin index can not be < 0");
    }
    if (end > size) {
        throw new IndexOutOfBoundsException("end index < " + size);
    }

    TDoubleLinkedList ret = new TDoubleLinkedList();
    TDoubleLink tmp = getLinkAt(begin);
    for (int i = begin; i < end; i++) {
        ret.add(tmp.getValue()); // copy
        tmp = tmp.getNext();
    }

    return ret;
}
 
开发者ID:JianpingZeng,项目名称:xcc,代码行数:27,代码来源:TDoubleLinkedList.java

示例3: equals

import gnu.trove.list.TDoubleList; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public boolean equals( Object other ) {
    if ( other == this ) {
        return true;
    }
    if ( !( other instanceof TDoubleList ) ) return false;

    TDoubleList that = ( TDoubleList )other;
    if ( size() != that.size() ) return false;

    for( int i = 0; i < size(); i++ ) {
        if ( get( i ) != that.get( i ) ) {
            return false;
        }
    }
    return true;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:19,代码来源:TDoubleLinkedList.java

示例4: subList

import gnu.trove.list.TDoubleList; //导入依赖的package包/类
/** {@inheritDoc} */
  @Override
  public TDoubleList subList( int begin, int end ) {
  	if ( end < begin ) {
	throw new IllegalArgumentException( "end index " + end +
		" greater than begin index " + begin );
}
if ( begin < 0 ) {
	throw new IndexOutOfBoundsException( "begin index can not be < 0" );
}
if ( end > _data.length ) {
	throw new IndexOutOfBoundsException( "end index < " + _data.length );
}
      TDoubleArrayList list = new TDoubleArrayList( end - begin );
      for ( int i = begin; i < end; i++ ) {
      	list.add( _data[ i ] );
      }
      return list;
  }
 
开发者ID:palantir,项目名称:trove-3.0.3,代码行数:20,代码来源:TDoubleArrayList.java

示例5: 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

示例6: sumprod

import gnu.trove.list.TDoubleList; //导入依赖的package包/类
public static double sumprod(TIntList fi, TDoubleList fv, double[][] w,
		int cl) {
	if (fi == null || fv == null || w == null) {
		logger.warn("[EXCEPTION]sumprod(" + fi + ", " + fv + "," + w
				+ ")@V has null argument.");
		return 0;
	}
	if (fi.size() != fv.size()) {
		logger.warn("[EXCEPTION]sumprod(fi=" + fi.size() + ", fv="
				+ fv.size() + ")@V has two lists in different lengths.");
		return 0;
	}
	if (cl > w.length || cl < 0) {
		logger.warn("[EXCEPTION]sumprod(cl=" + cl + ", w.len=" + w.length
				+ ")@V has different lengths.");
		return 0;
	}
	double result = 0;
	for (int i = 0; i < fi.size(); i++) {
		result += w[cl][fi.get(i)] * fv.get(i);
	}
	return result;
}
 
开发者ID:zhangcongle,项目名称:NewsSpikeRe,代码行数:24,代码来源:V.java

示例7: encodeIntoArray

import gnu.trove.list.TDoubleList; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
// Adapted from MultiEncoder
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void encodeIntoArray(DateTime inputData, int[] output) {

    if(inputData == null) {
        throw new IllegalArgumentException("DateEncoder requires a valid Date object but got null");
    }

    // Get the scalar values for each sub-field
    TDoubleList scalars = getScalars(inputData);

    int fieldCounter = 0;
    for (EncoderTuple t : getEncoders(this)) {
        Encoder encoder = t.getEncoder();
        int offset = t.getOffset();

        int[] tempArray = new int[encoder.getWidth()];
        encoder.encodeIntoArray(scalars.get(fieldCounter), tempArray);

        System.arraycopy(tempArray, 0, output, offset, tempArray.length);

        ++fieldCounter;
    }
}
 
开发者ID:numenta,项目名称:htm.java,代码行数:29,代码来源:DateEncoder.java

示例8: getBucketIndices

import gnu.trove.list.TDoubleList; //导入依赖的package包/类
/**
 * Returns an array containing the sub-field bucket indices for
 * each sub-field of the inputData. To get the associated field names for each of
 * the buckets, call getScalarNames().
 * @param  	input 	The data from the source. This is typically a object with members.
 *
 * @return 	array of bucket indices
 */
public int[] getBucketIndices(DateTime input) {

    TDoubleList scalars = getScalars(input);

    TIntList l = new TIntArrayList();
    List<EncoderTuple> encoders = getEncoders(this);
    if(encoders != null && encoders.size() > 0) {
        int i = 0;
        for(EncoderTuple t : encoders) {
            l.addAll(t.getEncoder().getBucketIndices(scalars.get(i)));
            ++i;
        }
    }else{
        throw new IllegalStateException("Should be implemented in base classes that are not " +
                "containers for other encoders");
    }
    return l.toArray();
}
 
开发者ID:numenta,项目名称:htm.java,代码行数:27,代码来源:DateEncoder.java

示例9: 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

示例10: anomalyScoreMovingAverage

import gnu.trove.list.TDoubleList; //导入依赖的package包/类
/**
 * Given a list of anomaly scores return a list of averaged records.
 * anomalyScores is assumed to be a list of records of the form:
 * <pre>
 *      Sample:
 *           dt = Tuple(2013, 8, 10, 23, 0) --> Date Fields
 *           sample = (double) 6.0
 *           metric(avg) = (double) 1.0
 * </pre>
 *           
 * @param anomalyScores     List of {@link Sample} objects (described contents above)
 * @param windowSize        Count of historical items over which to compute the average
 * 
 * @return Each record in the returned list contains [datetime field, value, averaged score]
 */
public AveragedAnomalyRecordList anomalyScoreMovingAverage(List<Sample> anomalyScores, int windowSize) {
    TDoubleList historicalValues = new TDoubleArrayList();
    double total = 0.0;
    List<Sample> averagedRecordList = new ArrayList<Sample>();
    for(Sample record : anomalyScores) {
        ////////////////////////////////////////////////////////////////////////////////////////////
        // Python version has check for malformed records here, but can't happen in java version. //
        ////////////////////////////////////////////////////////////////////////////////////////////
        
        Calculation calc = MovingAverage.compute(historicalValues, total, record.score, windowSize);
        
        Sample avgRecord = new Sample(
            record.date,
            record.value,
            calc.getAverage());
        averagedRecordList.add(avgRecord);
        total = calc.getTotal();
        
        if(LOG.isDebugEnabled()) {
            LOG.debug("Aggregating input record: {}, Result: {}", record, averagedRecordList.get(averagedRecordList.size() - 1));
        }
    }
    
    return new AveragedAnomalyRecordList(averagedRecordList, historicalValues, total);
}
 
开发者ID:numenta,项目名称:htm.java,代码行数:41,代码来源:AnomalyLikelihood.java

示例11: 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

示例12: testCloseInner

import gnu.trove.list.TDoubleList; //导入依赖的package包/类
@Ignore
private void testCloseInner(int[] bitmap1, int[] bitmap2, double expectedScore){
	PassThroughEncoder<int[]> encoder = new PassThroughEncoder<>(9, ArrayUtils.where(bitmap1, ArrayUtils.WHERE_1).length);
	encoder.setName("foo");
	
	int[] out1 = encoder.encode(bitmap1);
	encoder.setW(ArrayUtils.where(bitmap2, ArrayUtils.WHERE_1).length);
	int[] out2 = encoder.encode(bitmap2);

	TDoubleList result = encoder.closenessScores(new TDoubleArrayList(ArrayUtils.toDoubleArray(out1)), new TDoubleArrayList(ArrayUtils.toDoubleArray(out2)), true);
	assertTrue(result.size() == 1 );
	assertEquals(expectedScore, result.get(0), 0.0);
	
	encoder = PassThroughEncoder.builder()
			.n(9)
			.w(ArrayUtils.where(bitmap1, ArrayUtils.WHERE_1).length)
			.name("foo")
			.build();
	out1 = encoder.encode(bitmap1);
	encoder.setW(ArrayUtils.where(bitmap2, ArrayUtils.WHERE_1).length);
	out2 = encoder.encode(bitmap2);
	result = encoder.closenessScores(new TDoubleArrayList(ArrayUtils.toDoubleArray(out1)), new TDoubleArrayList(ArrayUtils.toDoubleArray(out2)), true);
	assertTrue(result.size() == 1 );
	assertEquals(expectedScore, result.get(0), 0.0);
}
 
开发者ID:numenta,项目名称:htm.java,代码行数:26,代码来源:PassThroughEncoderTest.java

示例13: testCloseness

import gnu.trove.list.TDoubleList; //导入依赖的package包/类
/**
 * Test closenessScores for a periodic encoder
 */
@Test
public void testCloseness() {
	setUp();
	builder.name("day of week")
        .w(7)
        .radius(1.0)
        .minVal(0.0)
        .maxVal(7.0)
        .periodic(true)
        .forced(true);
	initSE();
	
	TDoubleList expValues = new TDoubleArrayList(new double[] { 2, 4, 7 });
	TDoubleList actValues = new TDoubleArrayList(new double[] { 4, 2, 1 });
	
	TDoubleList scores = se.closenessScores(expValues, actValues, false);
	for(Tuple t : ArrayUtils.zip(Arrays.asList(2, 2, 1), Arrays.asList(scores.get(0)))) {
		double a = (int)t.get(0);
		double b = (double)t.get(1);
		assertTrue(a == b);
	}
}
 
开发者ID:numenta,项目名称:htm.java,代码行数:26,代码来源:ScalarEncoderTest.java

示例14: grep

import gnu.trove.list.TDoubleList; //导入依赖的package包/类
/** {@inheritDoc} */
public TDoubleList grep( TDoubleProcedure condition ) {
    TDoubleArrayList list = new TDoubleArrayList();
    for ( int i = 0; i < _pos; i++ ) {
        if ( condition.execute( _data[ i ] ) ) {
            list.add( _data[ i ] );
        }
    }
    return list;
}
 
开发者ID:JianpingZeng,项目名称:xcc,代码行数:11,代码来源:TDoubleArrayList.java

示例15: inverseGrep

import gnu.trove.list.TDoubleList; //导入依赖的package包/类
/** {@inheritDoc} */
public TDoubleList inverseGrep( TDoubleProcedure condition ) {
    TDoubleArrayList list = new TDoubleArrayList();
    for ( int i = 0; i < _pos; i++ ) {
        if ( !condition.execute( _data[ i ] ) ) {
            list.add( _data[ i ] );
        }
    }
    return list;
}
 
开发者ID:JianpingZeng,项目名称:xcc,代码行数:11,代码来源:TDoubleArrayList.java


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