Search in sources :

Example 6 with TIntArrayList

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());
}
Also used : IvMutableBlockPos(ivorius.ivtoolkit.blocks.IvMutableBlockPos) BlockPos(net.minecraft.util.math.BlockPos) TIntList(gnu.trove.list.TIntList) IvMutableBlockPos(ivorius.ivtoolkit.blocks.IvMutableBlockPos) TIntArrayList(gnu.trove.list.array.TIntArrayList)

Example 7 with TIntArrayList

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;
}
Also used : TIntArrayList(gnu.trove.list.array.TIntArrayList)

Example 8 with TIntArrayList

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("&amp;", "&");
        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();
}
Also used : TIntArrayList(gnu.trove.list.array.TIntArrayList)

Example 9 with TIntArrayList

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);
}
Also used : TIntList(gnu.trove.list.TIntList) TIntArrayList(gnu.trove.list.array.TIntArrayList)

Example 10 with TIntArrayList

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;
}
Also used : TIntProcedure(gnu.trove.procedure.TIntProcedure) State(edu.cmu.ml.proppr.prove.wam.State) TIntArrayList(gnu.trove.list.array.TIntArrayList) ArrayList(java.util.ArrayList) TIntArrayList(gnu.trove.list.array.TIntArrayList)

Aggregations

TIntArrayList (gnu.trove.list.array.TIntArrayList)10 Feature (edu.cmu.ml.proppr.prove.wam.Feature)2 TIntList (gnu.trove.list.TIntList)2 BlockPos (net.minecraft.util.math.BlockPos)2 Vector (ValkyrienWarfareBase.API.Vector)1 Outlink (edu.cmu.ml.proppr.prove.wam.Outlink)1 State (edu.cmu.ml.proppr.prove.wam.State)1 TIntDoubleIterator (gnu.trove.iterator.TIntDoubleIterator)1 TIntIterator (gnu.trove.iterator.TIntIterator)1 TIntDoubleHashMap (gnu.trove.map.hash.TIntDoubleHashMap)1 TIntObjectHashMap (gnu.trove.map.hash.TIntObjectHashMap)1 TIntProcedure (gnu.trove.procedure.TIntProcedure)1 TIntHashSet (gnu.trove.set.hash.TIntHashSet)1 IvMutableBlockPos (ivorius.ivtoolkit.blocks.IvMutableBlockPos)1 BufferedReader (java.io.BufferedReader)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 ArrayList (java.util.ArrayList)1