Java Code Examples for it.unimi.dsi.fastutil.doubles.DoubleList#size()

The following examples show how to use it.unimi.dsi.fastutil.doubles.DoubleList#size() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RandomInitializer.java    From samantha with MIT License 6 votes vote down vote up
public void randInitDoubleList(DoubleList doubleList, boolean normalize) {
    int size = doubleList.size();
    double sum = 0.0;
    for (int i=0; i<size; i++) {
        double val;
        if (normalize) {
            val = rand.nextDouble();
        } else {
            val = (rand.nextDouble() - subtract) * multi;
        }
        doubleList.set(i, val);
        if (normalize) {
            sum += val;
        }
    }
    if (normalize) {
        for (int i=0; i<size; i++) {
            doubleList.set(i, doubleList.getDouble(i) / sum);
        }
    }
}
 
Example 2
Source File: BootstrappingPreferenceKernel.java    From AILibs with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void signalNewScore(final ILabeledPath<N, A> path, final double newScore) {

	/* add the observation to all stats on the path */
	List<N> nodes = path.getNodes();
	int l = nodes.size();
	for (int i = l - 1; i >= 0; i --) {
		N node = nodes.get(i);
		DoubleList list = this.observations.computeIfAbsent(node, n -> new DoubleArrayList());
		list.add(newScore);
		if (list.size() > this.maxNumSamplesInHistory) {
			list.removeDouble(0);
		}
	}
}
 
Example 3
Source File: SynchronizedVariableSpace.java    From samantha with MIT License 5 votes vote down vote up
final public RealVector getScalarVarByName(String name) {
    readLock.lock();
    try {
        DoubleList var = scalarVars.get(name);
        double[] newVar = new double[var.size()];
        setDoubleList(newVar, var);
        return MatrixUtils.createRealVector(newVar);
    } finally {
        readLock.unlock();
    }
}
 
Example 4
Source File: ValueInTransformFunction.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
private static double[] filterDoubles(DoubleSet doubleSet, double[] source) {
  DoubleList doubleList = new DoubleArrayList();
  for (double value : source) {
    if (doubleSet.contains(value)) {
      doubleList.add(value);
    }
  }
  if (doubleList.size() == source.length) {
    return source;
  } else {
    return doubleList.toDoubleArray();
  }
}
 
Example 5
Source File: SynchronizedVariableSpace.java    From samantha with MIT License 4 votes vote down vote up
private void setDoubleList(DoubleList doubleList, double value) {
    int size = doubleList.size();
    for (int i=0; i<size; i++) {
        doubleList.set(i, value);
    }
}
 
Example 6
Source File: SynchronizedVariableSpace.java    From samantha with MIT License 4 votes vote down vote up
private void setDoubleList(DoubleList doubleList, RealVector vars) {
    int size = doubleList.size();
    for (int i=0; i<size; i++) {
        doubleList.set(i, vars.getEntry(i));
    }
}
 
Example 7
Source File: SynchronizedVariableSpace.java    From samantha with MIT License 4 votes vote down vote up
private void setDoubleList(double[] newVar, DoubleList var) {
    int size = var.size();
    for (int i=0; i<size; i++) {
        newVar[i] = var.getDouble(i);
    }
}