本文整理汇总了Java中cern.colt.list.IntArrayList类的典型用法代码示例。如果您正苦于以下问题:Java IntArrayList类的具体用法?Java IntArrayList怎么用?Java IntArrayList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IntArrayList类属于cern.colt.list包,在下文中一共展示了IntArrayList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNonZeros
import cern.colt.list.IntArrayList; //导入依赖的package包/类
public void getNonZeros(IntArrayList indexList, DoubleArrayList valueList) {
boolean fillIndexList = indexList != null;
boolean fillValueList = valueList != null;
if (fillIndexList)
indexList.clear();
else {
System.out.println("Wrong use");
return;
}
if (fillValueList)
valueList.clear();
else {
System.out.println("Wrong use");
return;
}
int[] index = elements.keys().elements();
double[] value = elements.values().elements();
indexList.elements(index);
valueList.elements(value);
// for (int i = 0; i < index.size(); ++i) {
// indexList.add(index.get(i));
// valueList.add(value.get(i));
// }
// int s = size;
// for (int i=0; i < s; i++) {
// double value = getQuick(i);
// if (value != 0) {
// if (fillIndexList) indexList.add(i);
// if (fillValueList) valueList.add(value);
// }
// }
}
示例2: SparseMultSparseTranspose
import cern.colt.list.IntArrayList; //导入依赖的package包/类
static public List<DoubleMatrix1D> SparseMultSparseTranspose(List<DoubleMatrix1D> A,
List<DoubleMatrix1D> B) {
int m = A.size();
int n = A.get(0).size();
int p = B.size();
List<DoubleMatrix1D> C = null;
if (C==null) {
C = new ArrayList<DoubleMatrix1D>();
for (int i = 0; i < m; ++i) {
C.add(new ColtSparseVector(p));
}
}
if (B.get(0).size() != n)
throw new IllegalArgumentException("Matrix2D inner dimensions must agree.");
for (int i = 0; i < m; ++i) {
IntArrayList indexList = new IntArrayList();
DoubleArrayList valueList = new DoubleArrayList();
A.get(i).getNonZeros(indexList, valueList);
for (int j = 0; j < p; ++j) {
if (B.get(j).size() != A.get(i).size())
throw new IllegalArgumentException("Matrix2D inner dimensions must agree.");
double sum = 0.0;
for (int k = 0; k < indexList.size(); ++k) {
int index = indexList.get(k);
double value1 = valueList.get(k);
double value2 = B.get(j).getQuick(index);
if (value1 != 0 || value2 != 0) {
sum += value1 * value2;
}
}
C.get(i).setQuick(j, sum);
}
}
return C;
}
示例3: getSparseTranspose
import cern.colt.list.IntArrayList; //导入依赖的package包/类
static public List<DoubleMatrix1D> getSparseTranspose(List<DoubleMatrix1D> A) {
List<DoubleMatrix1D> AT = new ArrayList<DoubleMatrix1D>();
for (int i = 0; i < A.get(0).size(); ++i) {
AT.add(new ColtSparseVector(A.size()));
}
for (int i = 0; i < A.size(); ++i) {
IntArrayList indexList = new IntArrayList();
DoubleArrayList valueList = new DoubleArrayList();
A.get(i).getNonZeros(indexList, valueList);
for (int k = 0; k < indexList.size(); ++k) {
int index = indexList.get(k);
double value = valueList.get(k);
AT.get(index).set(i, value);
}
}
return AT;
}
示例4: productQuick
import cern.colt.list.IntArrayList; //导入依赖的package包/类
static public double productQuick(DoubleMatrix1D v1, DoubleMatrix1D v2) {
IntArrayList indexList = new IntArrayList();
DoubleArrayList valueList = new DoubleArrayList();
v1.getNonZeros(indexList, valueList);
double prod = 0.0;
for (int i = 0; i < indexList.size(); ++i) {
double temp = v2.getQuick(indexList.getQuick(i));
if (temp != 0.0) {
prod += valueList.getQuick(i) * temp;
}
}
// for (int i = 0; i < v1.size(); ++i) {
// double temp1 = v1.getQuick(i);
// double temp2 = v2.getQuick(i);
// if (temp1 != 0.0 || temp2 != 0.0) {
// prod += temp1 * temp2;
// }
// }
return prod;
}
示例5: computeCosineSimilarity
import cern.colt.list.IntArrayList; //导入依赖的package包/类
public static double computeCosineSimilarity(IntArrayList indexA, DoubleArrayList valueA, DoubleMatrix1D B, DoubleArrayList valueB)
{
double sim = -1;
double num = 0;
double den = 0;
double den_1 = 0;
double den_2 = 0;
num = Matrix2DUtil.productQuick(indexA, valueA, B);
den_1 = Matrix2DUtil.getSqrSum(valueA);
den_2 = Matrix2DUtil.getSqrSum(valueB);
den = Math.sqrt(den_1) * Math.sqrt(den_2);
if(den == 0)
return 0;
sim = num/den;
return sim;
}
示例6: clone
import cern.colt.list.IntArrayList; //导入依赖的package包/类
public FSMInstance clone() {
Map<String, IntArrayList> bindsClone = new HashMap<String, IntArrayList>(bindings.size());
for(Map.Entry<String, IntArrayList> anEntry : bindings.entrySet()) {
bindsClone.put(anEntry.getKey(), anEntry.getValue().copy());
}
FSMInstance newInstance = new FSMInstance(annotationIndex, state, bindsClone, null);
newInstance.bindingStack = new IntArrayList[bindingStack.length];
int j, length;
for(int i = 0; i < bindingStackStored; i++){
if(bindingStack[i] != null){
newInstance.bindingStack[i] = new IntArrayList();
length = bindingStack[i].size();
for(j = 0; j < length; j++){
newInstance.bindingStack[i].add(bindingStack[i].get(j));
}
}
}
newInstance.bindingStackStored = bindingStackStored;
return newInstance;
}
示例7: bindAnnotations
import cern.colt.list.IntArrayList; //导入依赖的package包/类
/**
* Adds all input annotations to every annotation set stored in the binding stack.
*/
public void bindAnnotations(int[] aStep) {
int j;
for (int i = 0; i < bindingStackStored; i++) {
for (j = 0; j < aStep.length; j++) {
if (bindingStack[i] == null) {
bindingStack[i] = new IntArrayList();
}
if(aStep[j] >= 0) bindingStack[i].add(aStep[j]);
}
}
}
示例8: genInputPlaces
import cern.colt.list.IntArrayList; //导入依赖的package包/类
private ArrayList genInputPlaces(int ith)
{
ArrayList tuples = new ArrayList();
//get all predecessors
IntArrayList ialPred = getPred(ith, false);
//enumerate all the relevant causual dependencies
for (int i = 0; i < ialPred.size(); i++)
{
int pred = ialPred.get(i);
IntArrayList ialSucc = getSucc(pred, false);
for (int j = 0; j < ialSucc.size(); j++)
{
int succ = ialSucc.get(j);
IntArrayList A = new IntArrayList();
A.add(pred);
IntArrayList B = new IntArrayList();
B.add(succ);
ExpandTree(tuples, A, B, 0, 0);
}
}
return tuple2Place(ith, tuples, 1);
}
示例9: genOutputPlaces
import cern.colt.list.IntArrayList; //导入依赖的package包/类
private ArrayList genOutputPlaces(int ith)
{
ArrayList tuples = new ArrayList();
//get all successors
IntArrayList ialSucc = getSucc(ith, false);
//enumerate all the relevant causual dependencies
for (int i = 0; i < ialSucc.size(); i++)
{
int succ = ialSucc.get(i);
IntArrayList ialPred = getPred(succ, false);
for (int j = 0; j < ialPred.size(); j++)
{
int pred = ialPred.get(j);
IntArrayList A = new IntArrayList();
A.add(pred);
IntArrayList B = new IntArrayList();
B.add(succ);
ExpandTree(tuples, A, B, 0, 0);
}
}
return tuple2Place(ith, tuples, 0);
}
示例10: getPredPred
import cern.colt.list.IntArrayList; //导入依赖的package包/类
public IntArrayList getPredPred()
{
IntArrayList alTask = new IntArrayList();
for (int i = 0; i < alPred.size(); i++)
{
DoubleSet ds = (DoubleSet) alPred.get(i);
IntArrayList sarPred = ds.getA();
for (int j = 0; j < sarPred.size(); j++)
{
if (!alTask.contains(sarPred.get(j)))
{
alTask.add(sarPred.get(j));
}
}
}
return alTask;
}
示例11: getSuccSucc
import cern.colt.list.IntArrayList; //导入依赖的package包/类
public IntArrayList getSuccSucc()
{
IntArrayList alTask = new IntArrayList();
for (int i = 0; i < alSucc.size(); i++)
{
DoubleSet ds = (DoubleSet) alSucc.get(i);
IntArrayList sarSucc = ds.getB();
for (int j = 0; j < sarSucc.size(); j++)
{
if (!alTask.contains(sarSucc.get(j)))
{
alTask.add(sarSucc.get(j));
}
}
}
return alTask;
}
示例12: addNoise
import cern.colt.list.IntArrayList; //导入依赖的package包/类
public static void addNoise(DoubleMatrix2D s) {
IntArrayList is = new IntArrayList();
IntArrayList ks = new IntArrayList();
DoubleArrayList vs = new DoubleArrayList();
s.getNonZeros(is, ks, vs);
for (int j=0; j<is.size(); j++) {
int i = is.get(j);
int k = ks.get(j);
double v = vs.get(j);
v = v + (EPSILON * v + REALMIN100) * Math.random();
s.setQuick(i, k, v);
}
}
示例13: testGetNextPoissonSampleGof
import cern.colt.list.IntArrayList; //导入依赖的package包/类
@Test
public void testGetNextPoissonSampleGof() {
int N = 10000;
double[] array = new double[N];
Arrays.fill(array, 30);
Distribution[] distributions = IntStream.iterate(0, i -> i + 1).limit(N).mapToObj(i -> new PoissonDist(array[i])).toArray(Distribution[]::new);
SampleFactory.resetStartStream();
int[] samples = Arrays.stream(SampleFactory.getNextSample(distributions)).mapToInt(i -> (int) Math.round(i)).toArray();
IntArrayList list = new IntArrayList(samples);
DiscreteDistributionInt distribution = new PoissonDist(30);
int[] categories = new int[1];
double chi2Statistic = GofStat.chi2(
list,
distribution,
0,
(int) PoissonDist.inverseF(30, 0.999),
5,
categories);
assertTrue("Gof (Chi^2): "+chi2Statistic+">="+ChiSquareDist.inverseF(categories[0]-1, 0.95),
chi2Statistic <= ChiSquareDist.inverseF(categories[0]-1, 0.95));
}
示例14: testLargeMatrix_build1
import cern.colt.list.IntArrayList; //导入依赖的package包/类
/** Tests whether buildSolver works. */
@Test
public final void testLargeMatrix_build1()
{
for(int size=100;size<2100;size+=400)
for(int elemsPerColExp=0;elemsPerColExp< 7;elemsPerColExp++)
{
int elemsPerColExpected = (int)Math.pow(2, elemsPerColExp);
DoubleMatrix2D matrix = buildSolver(size,elemsPerColExpected).toDoubleMatrix2D();
IntArrayList CoordX = new IntArrayList(),CoordY = new IntArrayList();DoubleArrayList values = new DoubleArrayList();
matrix.getNonZeros(CoordY, CoordX, values);
int nz=CoordX.size();
int diagElements = 0, nondiagElements = 0;
for(int i=0;i<nz;++i)
{
if (CoordX.getQuick(i) == CoordY.getQuick(i))
{
Assert.assertEquals(1, values.getQuick(i),Configuration.fpAccuracy);diagElements++;
}
else nondiagElements++;
}
Assert.assertEquals(size, diagElements);
Assert.assertEquals(size*(elemsPerColExpected-1), nondiagElements);
}
}
示例15: observedEpsilonAtPhi
import cern.colt.list.IntArrayList; //导入依赖的package包/类
/**
* This method was created in VisualAge.
* @return double[]
* @param values cern.it.hepodbms.primitivearray.DoubleArrayList
* @param phis double[]
*/
public static double observedEpsilonAtPhi(double phi, ExactDoubleQuantileFinder exactFinder, DoubleQuantileFinder approxFinder) {
int N = (int) exactFinder.size();
int exactRank = (int) Utils.epsilonCeiling(phi * N) - 1;
//System.out.println("exactRank="+exactRank);
exactFinder.quantileElements(new DoubleArrayList(new double[] {phi})).get(0); // just to ensure exactFinder is sorted
double approxElement = approxFinder.quantileElements(new DoubleArrayList(new double[] {phi})).get(0);
//System.out.println("approxElem="+approxElement);
IntArrayList approxRanks = binaryMultiSearch(exactFinder.buffer, approxElement);
int from = approxRanks.get(0);
int to = approxRanks.get(1);
int distance;
if (from<=exactRank && exactRank<=to) distance = 0;
else {
if (from>exactRank) distance=Math.abs(from-exactRank);
else distance=Math.abs(exactRank-to);
}
double epsilon = (double)distance / (double)N;
return epsilon;
}