use of gnu.trove.list.array.TIntArrayList in project RecurrentComplex by Ivorforce.
the class RayAverageMatcher method getAverageGroundLevel.
// From StructureVillagePieces
public static int getAverageGroundLevel(boolean up, int y, StructureBoundingBox boundingBox, Predicate<BlockPos> predicate, int wHeight, double samples, Random random) {
TIntList list = new TIntArrayList(boundingBox.getXSize() * boundingBox.getZSize());
BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos();
for (int k = boundingBox.minZ; k <= boundingBox.maxZ; ++k) {
for (int l = boundingBox.minX; l <= boundingBox.maxX; ++l) {
// Added
if (samples >= 1 || random.nextDouble() < samples) {
pos.setPos(l, y, k);
// if (structurebb.isVecInside(pos))
{
list.add(findFirstBlock(pos, predicate, up, wHeight).getY());
}
}
}
}
if (list.isEmpty())
return -1;
else
return averageIgnoringErrors(list.toArray());
}
use of gnu.trove.list.array.TIntArrayList in project JGibbLabeledLDA by myleott.
the class Model method init.
//---------------------------------------------------------------
// Init Methods
//---------------------------------------------------------------
/**
* Init parameters for estimation or inference
*/
public boolean init(boolean random) {
if (random) {
M = data.M;
V = data.V;
z = new TIntArrayList[M];
} else {
if (!loadModel()) {
System.out.println("Fail to load word-topic assignment file of the model!");
return false;
}
// debug output
System.out.println("Model loaded:");
System.out.println("\talpha:" + alpha);
System.out.println("\tbeta:" + beta);
System.out.println("\tK:" + K);
System.out.println("\tM:" + M);
System.out.println("\tV:" + V);
}
p = new double[K];
initSS();
for (int m = 0; m < data.M; m++) {
if (random) {
z[m] = new TIntArrayList();
}
// initilize for z
int N = data.docs.get(m).length;
for (int n = 0; n < N; n++) {
int w = data.docs.get(m).words[n];
int topic;
// random init a topic or load existing topic from z[m]
if (random) {
topic = (int) Math.floor(Math.random() * K);
z[m].add(topic);
} else {
topic = z[m].get(n);
}
// number of instances of word assigned to topic j
nw[w][topic]++;
// number of words in document i assigned to topic j
nd[m][topic]++;
// total number of words assigned to topic j
nwsum[topic]++;
}
// total number of words in document i
ndsum[m] = N;
}
theta = new double[M][K];
phi = new double[K][V];
return true;
}
use of gnu.trove.list.array.TIntArrayList in project cogcomp-nlp by CogComp.
the class GazetteerViewGenerator method readGazzGivenInputStream.
private int readGazzGivenInputStream(BufferedReader reader) throws IOException {
TIntArrayList list = new TIntArrayList();
TIntArrayList lenList = new TIntArrayList();
int max = -1;
String line;
while ((line = reader.readLine()) != null) {
line = StringUtils.normalizeUnicodeDiacritics(line);
line = line.replaceAll("&", "&");
line = line.replaceAll("'", " '");
line = line.replaceAll(",", " ,");
line = line.replaceAll(";", " ;");
line = line.replaceAll("\\s+", " ");
line = line.trim();
list.add(line.hashCode());
int len = line.split("\\s+").length;
lenList.add(len);
if (len > max)
max = len;
}
this.patterns.add(list.toArray());
this.lengths.add(lenList.toArray());
this.maxLength = Math.max(max, this.maxLength);
return list.size();
}
use of gnu.trove.list.array.TIntArrayList in project RecurrentComplex by Ivorforce.
the class IntAreas method visitCoordsExcept.
public static boolean visitCoordsExcept(int[] lower, int[] higher, TIntList except, Visitor<int[]> visitor) {
TIntList dimensions = new TIntArrayList(Ranges.to(lower.length));
dimensions.removeAll(except);
return visitCoords(lower, higher, lower.clone(), dimensions, visitor);
}
use of gnu.trove.list.array.TIntArrayList in project ProPPR by TeamCohen.
the class LightweightStateGraph method near.
public List<State> near(State u) {
int ui = this.nodeTab.getId(u);
if (!near.containsKey(ui))
return DEFAULT_NEAR;
TIntArrayList vs = near.get(ui);
final ArrayList<State> ret = new ArrayList<State>(vs.size());
vs.forEach(new TIntProcedure() {
@Override
public boolean execute(int vi) {
ret.add(nodeTab.getSymbol(vi));
return true;
}
});
return ret;
}
Aggregations