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

Method stress

JSAT/src/jsat/datatransform/visualization/MDS.java:286–328  ·  view source on GitHub ↗
(final List<Vec> X_views, final List<Double> X_rowCache, final Matrix delta, ExecutorService ex)

Source from the content-addressed store, hash-verified

284 }
285
286 private static double stress(final List<Vec> X_views, final List<Double> X_rowCache, final Matrix delta, ExecutorService ex)
287 {
288 final AtomicDouble stress = new AtomicDouble(0);
289 final CountDownLatch latch = new CountDownLatch(SystemInfo.LogicalCores);
290
291 for(int id = 0; id < SystemInfo.LogicalCores; id++)
292 {
293 final int ID= id;
294 ex.submit(new Runnable()
295 {
296
297 @Override
298 public void run()
299 {
300 double localStress = 0;
301 for(int i = ID; i < delta.rows(); i+=SystemInfo.LogicalCores)
302 {
303
304 for(int j = i+1; j < delta.rows(); j++)
305 {
306 double tmp = embedMetric.dist(i, j, X_views, X_rowCache)-delta.get(i, j);
307 localStress += tmp*tmp;
308 }
309 }
310
311 stress.addAndGet(localStress);
312 latch.countDown();
313 }
314 });
315
316 }
317
318 try
319 {
320 latch.await();
321 }
322 catch (InterruptedException ex1)
323 {
324 Logger.getLogger(MDS.class.getName()).log(Level.SEVERE, null, ex1);
325 }
326
327 return stress.get();
328 }
329
330 @Override
331 public int getTargetDimension()

Callers 1

transformMethod · 0.95

Calls 5

getMethod · 0.95
submitMethod · 0.80
logMethod · 0.80
getNameMethod · 0.65
awaitMethod · 0.45

Tested by

no test coverage detected