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


Java IntIter类代码示例

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


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

示例1: getMarginal

import edu.jhu.prim.iter.IntIter; //导入依赖的package包/类
/**
 * Gets the marginal distribution over a subset of the variables in this
 * factor, optionally normalized.
 * 
 * @param vars The subset of variables for the marginal distribution. This will sum over all variables not in this set.
 * @param normalize Whether to normalize the resulting distribution.
 * @return The marginal distribution.
 */
public VarTensor getMarginal(VarSet vars, boolean normalize) {
    VarSet margVars = new VarSet(this.vars);
    margVars.retainAll(vars);
    
    VarTensor marg = new VarTensor(s, margVars, s.zero());
    if (margVars.size() == 0) {
        return marg;
    }
    
    IntIter iter = margVars.getConfigIter(this.vars);
    for (int i=0; i<this.values.length; i++) {
        int j = iter.next();
        marg.values[j] = s.plus(marg.values[j], this.values[i]);
    }
    
    if (normalize) {
        marg.normalize();
    }
    
    return marg;
}
 
开发者ID:mgormley,项目名称:pacaya,代码行数:30,代码来源:VarTensor.java

示例2: getClamped

import edu.jhu.prim.iter.IntIter; //导入依赖的package包/类
public VarTensor getClamped(VarConfig clmpVarConfig) {
    if (clmpVarConfig.size() == 0) {
        return new VarTensor(this);
    }
    VarSet clmpVars = clmpVarConfig.getVars();
    VarSet unclmpVars = new VarSet(this.vars);
    unclmpVars.removeAll(clmpVars); 

    VarTensor clmp = new VarTensor(s, unclmpVars);
    IntIter iter = IndexForVc.getConfigIter(this.vars, clmpVarConfig);
    
    if (clmp.values.length > 0) {
        for (int c=0; c<clmp.values.length; c++) {
            int config = iter.next();
            clmp.values[c] = this.values[config];
        }
    }
    return clmp;
}
 
开发者ID:mgormley,项目名称:pacaya,代码行数:20,代码来源:VarTensor.java

示例3: getPossibleRolePairs

import edu.jhu.prim.iter.IntIter; //导入依赖的package包/类
/**
 * Returns a list of pairs (i,j) for which a role variable should be built
 * according to the provided roleStructure.
 *
 * @param isent
 *            Sentence to get pairs for.
 * @param rS
 *            RoleStructure describing which pairs to include.
 * @param allowPredArgSelfLoops
 *            boolean indicating if pairs (i,i) should be included.
 * @return
 */
public static List<Pair<Integer, Integer>> getPossibleRolePairs(int n, IntSet knownPreds, Collection<Pair<Integer, Integer>> knownPairs, Collection<Pair<Integer, Integer>> pairsToSkip, RoleStructure rS,
        boolean allowPredArgSelfLoops) {
    List<Pair<Integer, Integer>> toReturn = new ArrayList<>();
    if (rS == RoleStructure.PAIRS_GIVEN) {
        toReturn.addAll(knownPairs);
        toReturn.sort(ComparablePair.naturalOrder());
    } else if (rS == RoleStructure.PREDS_GIVEN) {
        // CoNLL-friendly model; preds given
        IntIter iter = knownPreds.iterator();
        while (iter.hasNext()) {
            int i = iter.next();
            for (int j = 0; j < n; j++) {
                if (i == j && !allowPredArgSelfLoops) {
                    continue;
                }
                toReturn.add(new Pair<>(i, j));
            }
        }
    } else if (rS == RoleStructure.ALL_PAIRS) {
        // n**2 model
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (i != j || allowPredArgSelfLoops) {
                    toReturn.add(new Pair<>(i, j));
                }
            }
        }
    } else if (rS == RoleStructure.NO_ROLES) {
        // No role variables.
    } else {
        throw new IllegalArgumentException("Unsupported model structure: " + rS);
    }
    if (pairsToSkip != null) {
        toReturn.removeAll(pairsToSkip);
    }
    return toReturn;
}
 
开发者ID:mgormley,项目名称:pacaya-nlp,代码行数:50,代码来源:SrlFactorGraphBuilder.java

示例4: getConfigArr

import edu.jhu.prim.iter.IntIter; //导入依赖的package包/类
/**
 * Gets an array version of the configuration iterator.
 * @see edu.jhu.pacaya.gm.model.VarSet#getConfigIter
 */
public int[] getConfigArr(VarSet vars) {        
    IntArrayList a = new IntArrayList(vars.calcNumConfigs());
    IntIter iter = getConfigIter(vars);
    while (iter.hasNext()) {
        a.add(iter.next());
    }
    return a.toNativeArray();
}
 
开发者ID:mgormley,项目名称:pacaya,代码行数:13,代码来源:VarSet.java

示例5: getConfigArr

import edu.jhu.prim.iter.IntIter; //导入依赖的package包/类
/**
 * Gets an array version of the configuration iterator.
 * @see edu.jhu.pacaya.gm.model.IndexForVc#getConfigIter
 */
public static int[] getConfigArr(VarSet vars, VarConfig config) {        
    IntArrayList a = new IntArrayList(config.getVars().calcNumConfigs());
    IntIter iter = getConfigIter(vars, config);
    while (iter.hasNext()) {
        a.add(iter.next());
    }
    return a.toNativeArray();
}
 
开发者ID:mgormley,项目名称:pacaya,代码行数:13,代码来源:IndexForVc.java

示例6: iterator

import edu.jhu.prim.iter.IntIter; //导入依赖的package包/类
public IntIter iterator() {
    return new IntArrayIter(map.getIndices());
}
 
开发者ID:mgormley,项目名称:prim,代码行数:4,代码来源:IntHashSet.java

示例7: indices

import edu.jhu.prim.iter.IntIter; //导入依赖的package包/类
public IntIter indices() {
    return new SparseIdxIter(idx, top);
}
 
开发者ID:mgormley,项目名称:prim,代码行数:4,代码来源:IntDoubleUnsortedVector.java

示例8: getConfigIter

import edu.jhu.prim.iter.IntIter; //导入依赖的package包/类
/**
 * Gets an iterator over the configurations of the variables for this
 * variable set, such that the c'th configuration in the iterator will
 * correspond to the variable setting where all the values of the
 * variables in this set take on the same values as the c'th
 * configuration of the variables in vars, and all the other variables
 * take on the zero state.
 * 
 * This is a trick from libDAI for efficiently computing factor
 * products.
 * 
 * @param vars The variable set to which the iterator should be aligned.
 * @return The iterator.
 */
public IntIter getConfigIter(VarSet vars) {
    return new IndexFor(this, vars);
}
 
开发者ID:mgormley,项目名称:pacaya,代码行数:18,代码来源:VarSet.java

示例9: iterator

import edu.jhu.prim.iter.IntIter; //导入依赖的package包/类
IntIter iterator(); 
开发者ID:mgormley,项目名称:prim,代码行数:2,代码来源:IntSet.java


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