@Override public void init(int capacity) { if (data == null) { this.capacity = capacity; data = new OpenIntDoubleHashMap(); } }
int i = indexOfInsertion(key); if (i<0) { //already contained i = -i -1; int newCapacity = chooseGrowCapacity(this.distinct+1,this.minLoadFactor, this.maxLoadFactor); rehash(newCapacity); return put(key, value); int newCapacity = chooseGrowCapacity(this.distinct+1,this.minLoadFactor, this.maxLoadFactor); rehash(newCapacity);
int i = indexOfKey(key); if (i<0) return false; // key not contained int newCapacity = chooseShrinkCapacity(this.distinct,this.minLoadFactor, this.maxLoadFactor); rehash(newCapacity);
OpenIntDoubleHashMap categoryDistribution = new OpenIntDoubleHashMap(); int sumCount = 0; OpenIntIntHashMap[] topicWordCountArray = rootNode.getTopicWordCountArray(); OpenIntDoubleHashMap[] topicWordDistributionArray = new OpenIntDoubleHashMap[topicWordCountArray.length]; for (int i = 0; i < topicWordCountArray.length; ++i) { topicWordDistributionArray[i] = new OpenIntDoubleHashMap(); IntArrayList indexList = topicWordCountArray[i].keys(); int sumLocalCount = 0; int index = indexList.get(j); int wordCount = topicWordCountArray[i].get(index); topicWordDistributionArray[i].put(index, (wordCount + globalBeta) / (sumLocalCount * globalBeta * this.globalWordNum )); for (int j = 0; j < indexList.size(); ++j) { int index = indexList.get(j); double prob = topicWordDistributionArray[i].get(index); double cateProb = categoryDistribution.get(index); categoryDistribution.put(index, cateProb + prob); IntArrayList indexList = categoryDistribution.keys(); double sum = 0; for (int j = 0; j < indexList.size(); ++j) { sum += categoryDistribution.get(indexList.get(j)); if (categoryDistribution.get(indexList.get(j)) != 0 ) { categoryDistribution.put(indexList.get(j), categoryDistribution.get(indexList.get(j)) / sum ); System.out.print(" Node [" + rootNode.getLabelString() + "] top keywords : "); List<LabelKeyValuePair> kvpList = new ArrayList<LabelKeyValuePair>();
byte newState[] = new byte[newCapacity]; this.lowWaterMark = chooseLowWaterMark(newCapacity,this.minLoadFactor); this.highWaterMark = chooseHighWaterMark(newCapacity,this.maxLoadFactor); if (oldState[i]==FULL) { int element = oldTable[i]; int index = indexOfInsertion(element); newTable[index]=element; newValues[index]=oldValues[i];
@Override public double getValue(int pos) { checkPos(pos); double result = defaultValue; if (data.containsKey(pos)) { result = data.get(pos); } return result; }
int capacity = initialCapacity; super.setUp(capacity, minLoadFactor, maxLoadFactor); capacity = nextPrime(capacity); if (capacity==0) capacity=1; // open addressing needs at least one FREE slot at any time. this.highWaterMark = chooseHighWaterMark(capacity, this.maxLoadFactor);
/** * DOCUMENT ME! * * @param node_index DOCUMENT ME! * @param att_id DOCUMENT ME! * @param value DOCUMENT ME! * * @return DOCUMENT ME! */ public static int setNodeAttributeDoubleValue(int node_index, int att_id, double value) { // return if higher than the number of attributes if (att_id > nodeAttributeCount) return INSANE_ATTRIBUTE_ID; // make sure that the attribute type is correct if (getNodeAttIDToAttTypeMap().get(att_id) != DOUBLE_TYPE) return WRONG_ATTRIBUTE_TYPE; OpenIntDoubleHashMap double_map = (OpenIntDoubleHashMap) getNodeAttributeIDToAttributeValuesMap() .get(att_id); double_map.put(node_index, value); return 1; }
/** * Clears the receiver, then adds all (key,value) pairs of <tt>other</tt>values to it. * * @param other the other map to be copied into the receiver. */ public void assign(AbstractIntDoubleMap other) { if (!(other instanceof OpenIntDoubleHashMap)) { super.assign(other); return; } OpenIntDoubleHashMap source = (OpenIntDoubleHashMap) other; OpenIntDoubleHashMap copy = (OpenIntDoubleHashMap) source.copy(); this.values = copy.values; this.table = copy.table; this.state = copy.state; this.freeEntries = copy.freeEntries; this.distinct = copy.distinct; this.lowWaterMark = copy.lowWaterMark; this.highWaterMark = copy.highWaterMark; this.minLoadFactor = copy.minLoadFactor; this.maxLoadFactor = copy.maxLoadFactor; } /**
/** Assigns the result of a function to each value; <tt>v[i] = function(v[i])</tt>. @param function a function object taking as argument the current association's value. */ public void assign(cern.colt.function.DoubleFunction function) { // specialization for speed if (function instanceof cern.jet.math.Mult) { // x[i] = mult*x[i] double multiplicator = ((cern.jet.math.Mult)function).multiplicator; if (multiplicator==1) return; if (multiplicator==0) { clear(); return; } for (int i = table.length ; i-- > 0 ;) { if (state[i]==FULL) values[i] *= multiplicator; } } else { // the general case x[i] = f(x[i]) for (int i = table.length ; i-- > 0 ;) { if (state[i]==FULL) values[i] = function.apply(values[i]); } } } /**
docCount -= 1; double wordProb = candidateTopicWordDistribution.get(topicId).get(wordId); int sumWordCount = candidateTopicWordNumSum.get(topicId);
/** * Returns all Attributes that one or more of the given nodes have values for. */ public static String[] getNodeAttributes(int[] node_indices) { IntArrayList att_keys = new IntArrayList(); getNodeAttributeIDToAttributeValuesMap().keys(att_keys); HashSet attributes = new HashSet(); for (int k = 0; k < att_keys.size(); ++k) { for (int i = 0; i < node_indices.length; ++i) { if (att_keys.get(k) == DOUBLE_TYPE) { OpenIntDoubleHashMap n2v = (OpenIntDoubleHashMap) getNodeAttributeIDToAttributeValuesMap() .get(att_keys.get(k)); if (n2v.containsKey(node_indices[i])) { attributes.add(getNodeAttIDToAttNameMap().get(att_keys.get(k))); // don't look at anymore nodes i = node_indices.length; } } else { OpenIntObjectHashMap n2v = (OpenIntObjectHashMap) getNodeAttributeIDToAttributeValuesMap() .get(att_keys.get(k)); if (n2v.containsKey(node_indices[i])) { attributes.add(getNodeAttIDToAttNameMap().get(att_keys.get(k))); // don't look at anymore nodes i = node_indices.length; } } } } return (String[]) attributes.toArray(new String[] { }); }
int i = indexOfKey(key); if (i<0) return false; // key not contained int newCapacity = chooseShrinkCapacity(this.distinct,this.minLoadFactor, this.maxLoadFactor); rehash(newCapacity);
byte newState[] = new byte[newCapacity]; this.lowWaterMark = chooseLowWaterMark(newCapacity, this.minLoadFactor); this.highWaterMark = chooseHighWaterMark(newCapacity, this.maxLoadFactor); if (oldState[i] == FULL) { int element = oldTable[i]; int index = indexOfInsertion(element); newTable[index] = element; newValues[index] = oldValues[i];
/** * DOCUMENT ME! * * @param node_index DOCUMENT ME! * @param attribute DOCUMENT ME! * * @return DOCUMENT ME! */ public static double getNodeAttributeDoubleValue(int node_index, String attribute) { int att_id = getNodeAttributeID(attribute); if (att_id < 0) return Double.NaN; int att_type = getNodeAttIDToAttTypeMap().get(att_id); if (att_type == DOUBLE_TYPE) { OpenIntObjectHashMap a2v = getNodeAttributeIDToAttributeValuesMap(); OpenIntDoubleHashMap n2v = (OpenIntDoubleHashMap) getNodeAttributeIDToAttributeValuesMap() .get(att_id); if (n2v == null) { CyLogger.getLogger().info("Internal error: Unable to get node attribute id map"); return Double.NaN; } if (n2v.containsKey(node_index)) return n2v.get(node_index); // return ( ( OpenIntDoubleHashMap )getNodeAttributeIDToAttributeValuesMap().get( att_id )).get( node_index ); } return Double.NaN; }
int capacity = initialCapacity; super.setUp(capacity, minLoadFactor, maxLoadFactor); capacity = nextPrime(capacity); if (capacity==0) capacity=1; // open addressing needs at least one FREE slot at any time. this.highWaterMark = chooseHighWaterMark(capacity, this.maxLoadFactor);
/** * Clears the receiver, then adds all (key,value) pairs of <tt>other</tt>values to it. * * @param other the other map to be copied into the receiver. */ public void assign(AbstractIntDoubleMap other) { if (!(other instanceof OpenIntDoubleHashMap)) { super.assign(other); return; } OpenIntDoubleHashMap source = (OpenIntDoubleHashMap) other; OpenIntDoubleHashMap copy = (OpenIntDoubleHashMap) source.copy(); this.values = copy.values; this.table = copy.table; this.state = copy.state; this.freeEntries = copy.freeEntries; this.distinct = copy.distinct; this.lowWaterMark = copy.lowWaterMark; this.highWaterMark = copy.highWaterMark; this.minLoadFactor = copy.minLoadFactor; this.maxLoadFactor = copy.maxLoadFactor; } /**
/** Assigns the result of a function to each value; <tt>v[i] = function(v[i])</tt>. @param function a function object taking as argument the current association's value. */ public void assign(cern.colt.function.DoubleFunction function) { // specialization for speed if (function instanceof cern.jet.math.Mult) { // x[i] = mult*x[i] double multiplicator = ((cern.jet.math.Mult)function).multiplicator; if (multiplicator==1) return; if (multiplicator==0) { clear(); return; } for (int i = table.length ; i-- > 0 ;) { if (state[i]==FULL) values[i] *= multiplicator; } } else { // the general case x[i] = f(x[i]) for (int i = table.length ; i-- > 0 ;) { if (state[i]==FULL) values[i] = function.apply(values[i]); } } } /**