Java Code Examples for cern.colt.list.IntArrayList#get()
The following examples show how to use
cern.colt.list.IntArrayList#get() .
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: QuantileFinderTest.java From database with GNU General Public License v2.0 | 6 votes |
/** * 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; }
Example 2
Source File: AbstractIntDoubleMap.java From database with GNU General Public License v2.0 | 6 votes |
/** * Returns a string representation of the receiver, containing * the String representation of each key-value pair, sorted ascending by key. */ public String toString() { IntArrayList theKeys = keys(); String tmp = theKeys.toString() + "\n"; theKeys.sort(); StringBuffer buf = new StringBuffer(tmp); //StringBuffer buf = new StringBuffer(); buf.append("["); int maxIndex = theKeys.size() - 1; for (int i = 0; i <= maxIndex; i++) { int key = theKeys.get(i); buf.append(String.valueOf(key)); buf.append("->"); buf.append(String.valueOf(get(key))); if (i < maxIndex) buf.append(", "); } buf.append("]"); return buf.toString(); }
Example 3
Source File: AbstractIntDoubleMap.java From database with GNU General Public License v2.0 | 6 votes |
/** * Returns a string representation of the receiver, containing * the String representation of each key-value pair, sorted ascending by value. */ public String toStringByValue() { IntArrayList theKeys = new IntArrayList(); keysSortedByValue(theKeys); StringBuffer buf = new StringBuffer(); buf.append("["); int maxIndex = theKeys.size() - 1; for (int i = 0; i <= maxIndex; i++) { int key = theKeys.get(i); buf.append(String.valueOf(key)); buf.append("->"); buf.append(String.valueOf(get(key))); if (i < maxIndex) buf.append(", "); } buf.append("]"); return buf.toString(); }
Example 4
Source File: AbstractIntObjectMap.java From database with GNU General Public License v2.0 | 6 votes |
/** * Returns a string representation of the receiver, containing * the String representation of each key-value pair, sorted ascending by key. */ public String toString() { IntArrayList theKeys = keys(); theKeys.sort(); StringBuffer buf = new StringBuffer(); buf.append("["); int maxIndex = theKeys.size() - 1; for (int i = 0; i <= maxIndex; i++) { int key = theKeys.get(i); buf.append(String.valueOf(key)); buf.append("->"); buf.append(String.valueOf(get(key))); if (i < maxIndex) buf.append(", "); } buf.append("]"); return buf.toString(); }
Example 5
Source File: AbstractIntObjectMap.java From database with GNU General Public License v2.0 | 6 votes |
/** * Returns a string representation of the receiver, containing * the String representation of each key-value pair, sorted ascending by value, according to natural ordering. */ public String toStringByValue() { IntArrayList theKeys = new IntArrayList(); keysSortedByValue(theKeys); StringBuffer buf = new StringBuffer(); buf.append("["); int maxIndex = theKeys.size() - 1; for (int i = 0; i <= maxIndex; i++) { int key = theKeys.get(i); buf.append(String.valueOf(key)); buf.append("->"); buf.append(String.valueOf(get(key))); if (i < maxIndex) buf.append(", "); } buf.append("]"); return buf.toString(); }
Example 6
Source File: AbstractIntIntMap.java From database with GNU General Public License v2.0 | 6 votes |
/** * Returns a string representation of the receiver, containing * the String representation of each key-value pair, sorted ascending by key. */ public String toString() { IntArrayList theKeys = keys(); //theKeys.sort(); StringBuffer buf = new StringBuffer(); buf.append("["); int maxIndex = theKeys.size() - 1; for (int i = 0; i <= maxIndex; i++) { int key = theKeys.get(i); buf.append(String.valueOf(key)); buf.append("->"); buf.append(String.valueOf(get(key))); if (i < maxIndex) buf.append(", "); } buf.append("]"); return buf.toString(); }
Example 7
Source File: AbstractIntIntMap.java From database with GNU General Public License v2.0 | 6 votes |
/** * Returns a string representation of the receiver, containing * the String representation of each key-value pair, sorted ascending by value. */ public String toStringByValue() { IntArrayList theKeys = new IntArrayList(); keysSortedByValue(theKeys); StringBuffer buf = new StringBuffer(); buf.append("["); int maxIndex = theKeys.size() - 1; for (int i = 0; i <= maxIndex; i++) { int key = theKeys.get(i); buf.append(String.valueOf(key)); buf.append("->"); buf.append(String.valueOf(get(key))); if (i < maxIndex) buf.append(", "); } buf.append("]"); return buf.toString(); }
Example 8
Source File: QuantileFinderTest.java From jAudioGIT with GNU Lesser General Public License v2.1 | 6 votes |
/** * 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; }
Example 9
Source File: AbstractIntDoubleMap.java From jAudioGIT with GNU Lesser General Public License v2.1 | 6 votes |
/** * Returns a string representation of the receiver, containing * the String representation of each key-value pair, sorted ascending by key. */ public String toString() { IntArrayList theKeys = keys(); String tmp = theKeys.toString() + "\n"; theKeys.sort(); StringBuffer buf = new StringBuffer(tmp); //StringBuffer buf = new StringBuffer(); buf.append("["); int maxIndex = theKeys.size() - 1; for (int i = 0; i <= maxIndex; i++) { int key = theKeys.get(i); buf.append(String.valueOf(key)); buf.append("->"); buf.append(String.valueOf(get(key))); if (i < maxIndex) buf.append(", "); } buf.append("]"); return buf.toString(); }
Example 10
Source File: AbstractIntDoubleMap.java From jAudioGIT with GNU Lesser General Public License v2.1 | 6 votes |
/** * Returns a string representation of the receiver, containing * the String representation of each key-value pair, sorted ascending by value. */ public String toStringByValue() { IntArrayList theKeys = new IntArrayList(); keysSortedByValue(theKeys); StringBuffer buf = new StringBuffer(); buf.append("["); int maxIndex = theKeys.size() - 1; for (int i = 0; i <= maxIndex; i++) { int key = theKeys.get(i); buf.append(String.valueOf(key)); buf.append("->"); buf.append(String.valueOf(get(key))); if (i < maxIndex) buf.append(", "); } buf.append("]"); return buf.toString(); }
Example 11
Source File: AbstractIntObjectMap.java From jAudioGIT with GNU Lesser General Public License v2.1 | 6 votes |
/** * Returns a string representation of the receiver, containing * the String representation of each key-value pair, sorted ascending by key. */ public String toString() { IntArrayList theKeys = keys(); theKeys.sort(); StringBuffer buf = new StringBuffer(); buf.append("["); int maxIndex = theKeys.size() - 1; for (int i = 0; i <= maxIndex; i++) { int key = theKeys.get(i); buf.append(String.valueOf(key)); buf.append("->"); buf.append(String.valueOf(get(key))); if (i < maxIndex) buf.append(", "); } buf.append("]"); return buf.toString(); }
Example 12
Source File: AbstractIntObjectMap.java From jAudioGIT with GNU Lesser General Public License v2.1 | 6 votes |
/** * Returns a string representation of the receiver, containing * the String representation of each key-value pair, sorted ascending by value, according to natural ordering. */ public String toStringByValue() { IntArrayList theKeys = new IntArrayList(); keysSortedByValue(theKeys); StringBuffer buf = new StringBuffer(); buf.append("["); int maxIndex = theKeys.size() - 1; for (int i = 0; i <= maxIndex; i++) { int key = theKeys.get(i); buf.append(String.valueOf(key)); buf.append("->"); buf.append(String.valueOf(get(key))); if (i < maxIndex) buf.append(", "); } buf.append("]"); return buf.toString(); }
Example 13
Source File: AbstractIntIntMap.java From jAudioGIT with GNU Lesser General Public License v2.1 | 6 votes |
/** * Returns a string representation of the receiver, containing * the String representation of each key-value pair, sorted ascending by key. */ public String toString() { IntArrayList theKeys = keys(); //theKeys.sort(); StringBuffer buf = new StringBuffer(); buf.append("["); int maxIndex = theKeys.size() - 1; for (int i = 0; i <= maxIndex; i++) { int key = theKeys.get(i); buf.append(String.valueOf(key)); buf.append("->"); buf.append(String.valueOf(get(key))); if (i < maxIndex) buf.append(", "); } buf.append("]"); return buf.toString(); }
Example 14
Source File: AbstractIntIntMap.java From jAudioGIT with GNU Lesser General Public License v2.1 | 6 votes |
/** * Returns a string representation of the receiver, containing * the String representation of each key-value pair, sorted ascending by value. */ public String toStringByValue() { IntArrayList theKeys = new IntArrayList(); keysSortedByValue(theKeys); StringBuffer buf = new StringBuffer(); buf.append("["); int maxIndex = theKeys.size() - 1; for (int i = 0; i <= maxIndex; i++) { int key = theKeys.get(i); buf.append(String.valueOf(key)); buf.append("->"); buf.append(String.valueOf(get(key))); if (i < maxIndex) buf.append(", "); } buf.append("]"); return buf.toString(); }
Example 15
Source File: ScanningAlgorithm.java From CFGScanDroid with GNU General Public License v2.0 | 5 votes |
public static SparseDoubleMatrix2D reduceCandidateList(IntArrayList signatureNonZeros, IntArrayList functionNonZeros, SparseDoubleMatrix2D candidateList) { // reduce for(int i=0; i<signatureNonZeros.size(); ++i) { // find nodes with only one possible candidate if(candidateList.viewRow(signatureNonZeros.get(i)).cardinality() == 1) { int nonZero = -1; for(int j=0; j<functionNonZeros.size(); ++j) { if(candidateList.get(signatureNonZeros.get(i), functionNonZeros.get(j)) != 0.0) { nonZero = functionNonZeros.get(j); break; } } if(nonZero == -1){ System.out.println("REDUCE LOOP IS BROKEN - J NOT FOUND"); System.out.println(signatureNonZeros); System.out.println(functionNonZeros); System.out.println(candidateList); System.out.println(); break; } // remove candidacy of other nodes since it /has/ to be that one node for(int x=0; x<signatureNonZeros.size(); ++x) { if(x != i) { candidateList.set(signatureNonZeros.get(x), nonZero, 0.0); } } } } return candidateList; }
Example 16
Source File: ScanningAlgorithm.java From CFGScanDroid with GNU General Public License v2.0 | 4 votes |
public static boolean bipartiteMatchingVector(DoubleMatrix2D candidateList, DoubleMatrix2D signatureNodeVector, DoubleMatrix2D functionNodeVector, int[] signatureDepths, int[] functionDepths) { UndirectedGraph<String, DefaultEdge> g = new SimpleGraph<String, DefaultEdge>(DefaultEdge.class); IntArrayList signatureNonZeros = new IntArrayList(); IntArrayList functionNonZeros = new IntArrayList(); IntArrayList unusedInt = new IntArrayList(); DoubleArrayList unusedDouble = new DoubleArrayList(); // get set column indices for signature vector and function vector signatureNodeVector.getNonZeros(unusedInt, signatureNonZeros, unusedDouble); functionNodeVector.getNonZeros(unusedInt, functionNonZeros, unusedDouble); List<String> signatureIdcs = new ArrayList<String>(); List<String> functionIdcs = new ArrayList<String>(); int signatureNodeCount = 0; // add signature nodes graph for(int i=0; i<signatureNonZeros.size(); ++i) { int signatureIdx = signatureNonZeros.get(i); if(signatureDepths[signatureIdx] != -1) { signatureIdcs.add("s"+signatureIdx); g.addVertex("s"+signatureIdx); signatureNodeCount++; } } // add function nodes graph for(int j=0; j<functionNonZeros.size(); ++j) { int functionIdx = functionNonZeros.get(j); if(functionDepths[functionIdx] != -1) { functionIdcs.add("f"+functionNonZeros.get(j)); g.addVertex("f"+functionNonZeros.get(j)); } } // add edges for(int i=0; i<signatureNonZeros.size(); ++i) { for(int j=0; j<functionNonZeros.size(); ++j) { if(candidateList.get(signatureNonZeros.get(i), functionNonZeros.get(j)) != 0) { g.addEdge("s"+signatureNonZeros.get(i), "f"+functionNonZeros.get(j)); } } } // define sets Set<String> p1 = new HashSet<String>(signatureIdcs); Set<String> p2 = new HashSet<String>(functionIdcs); // bipartite matching! HopcroftKarpBipartiteMatching<String, DefaultEdge> alg = new HopcroftKarpBipartiteMatching<String, DefaultEdge>(g, p1, p2); Set<DefaultEdge> match = alg.getMatching(); // sat || unsat if(match.size() == signatureNodeCount) { return true; } else { return false; } }