MCPcopy Create free account
hub / github.com/EdwardRaff/JSAT / increment

Method increment

JSAT/src/jsat/linear/SparseVector.java:203–219  ·  view source on GitHub ↗

Increments the value at the given index by the given value. @param index the index of the value to alter @param val the value to be added to the index

(int index, double val)

Source from the content-addressed store, hash-verified

201 * @param val the value to be added to the index
202 */
203 @Override
204 public void increment(int index, double val)
205 {
206 if (index > length - 1 || index < 0)
207 throw new IndexOutOfBoundsException("Can not access an index larger then the vector or a negative index");
208 if(val == 0)//donst want to insert a zero, and a zero changes nothing
209 return;
210 int location = Arrays.binarySearch(indexes, 0, used, index);
211 if(location < 0)
212 insertValue(location, index, val);
213 else
214 {
215 values[location]+=val;
216 if(values[location] == 0.0)
217 removeNonZero(location);
218 }
219 }
220
221 @Override
222 public double get(int index)

Callers 3

newTextMethod · 0.95
newTextMethod · 0.95
multiplyMethod · 0.45

Calls 2

insertValueMethod · 0.95
removeNonZeroMethod · 0.95

Tested by

no test coverage detected