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

Method set

JSAT/src/jsat/linear/SparseVector.java:235–255  ·  view source on GitHub ↗
(int index, double val)

Source from the content-addressed store, hash-verified

233 }
234
235 @Override
236 public void set(int index, double val)
237 {
238 if(index > length()-1 || index < 0)
239 throw new IndexOutOfBoundsException(index + " does not fit in [0," + length + ")");
240
241
242 clearCaches();
243 int insertLocation = Arrays.binarySearch(indexes, 0, used, index);
244 if(insertLocation >= 0)
245 {
246 if(val != 0)//set it
247 values[insertLocation] = val;
248 else//shift used count and everyone over
249 {
250 removeNonZero(insertLocation);
251 }
252 }
253 else if(val != 0)//dont insert 0s, that is stupid
254 insertValue(insertLocation, index, val);
255 }
256
257 /**
258 * Takes the negative insert location value returned by {@link Arrays#binarySearch(int[], int, int, int) }

Callers 8

testModelMethod · 0.95
mutableAddMethod · 0.95
changeSizeMethod · 0.95
trainCMethod · 0.95
transformMethod · 0.95
loadGMethod · 0.95
transformMethod · 0.95
addOriginalDocumentMethod · 0.95

Calls 4

lengthMethod · 0.95
clearCachesMethod · 0.95
removeNonZeroMethod · 0.95
insertValueMethod · 0.95

Tested by 1

testModelMethod · 0.76