/** * Adds a value to a vector. * * @param originalForm1 The original form of the first value as a byte array. * @param originalForm2 The original form of the second value as a byte array. * @param weight How much to weight this interaction * @param data The vector to which the value should be added. */ public void addInteractionToVector(byte[] originalForm1, byte[] originalForm2, double weight, Vector data) { String name = getName(); double w = getWeight(originalForm1, originalForm2, weight); for (int i = 0; i < probes(); i++) { Iterable<Integer> jValues = secondEncoder.hashesForProbe(originalForm2, data.size(), name, i % secondEncoder.getProbes()); for (Integer k : firstEncoder.hashesForProbe(originalForm1, data.size(), name, i % firstEncoder.getProbes())) { for (Integer j : jValues) { int n = (k + j) % data.size(); if (isTraceEnabled()) { trace(String.format("%s:%s", new String(originalForm1, Charsets.UTF_8), new String(originalForm2, Charsets.UTF_8)), n); } data.set(n, data.get(n) + w); } } } }
/** * Adds a value to a vector. * * @param originalForm1 The original form of the first value as a byte array. * @param originalForm2 The original form of the second value as a byte array. * @param weight How much to weight this interaction * @param data The vector to which the value should be added. */ public void addInteractionToVector(byte[] originalForm1, byte[] originalForm2, double weight, Vector data) { String name = getName(); double w = getWeight(originalForm1, originalForm2, weight); for (int i = 0; i < probes(); i++) { Iterable<Integer> jValues = secondEncoder.hashesForProbe(originalForm2, data.size(), name, i % secondEncoder.getProbes()); for (Integer k : firstEncoder.hashesForProbe(originalForm1, data.size(), name, i % firstEncoder.getProbes())) { for (Integer j : jValues) { int n = (k + j) % data.size(); if (isTraceEnabled()) { trace(String.format("%s:%s", new String(originalForm1, Charsets.UTF_8), new String(originalForm2, Charsets.UTF_8)), n); } data.set(n, data.get(n) + w); } } } }
/** * Adds a value to a vector. * * @param originalForm1 The original form of the first value as a byte array. * @param originalForm2 The original form of the second value as a byte array. * @param weight How much to weight this interaction * @param data The vector to which the value should be added. */ public void addInteractionToVector(byte[] originalForm1, byte[] originalForm2, double weight, Vector data) { String name = getName(); double w = getWeight(originalForm1, originalForm2, weight); for (int i = 0; i < probes(); i++) { Iterable<Integer> jValues = secondEncoder.hashesForProbe(originalForm2, data.size(), name, i % secondEncoder.getProbes()); for (Integer k : firstEncoder.hashesForProbe(originalForm1, data.size(), name, i % firstEncoder.getProbes())) { for (Integer j : jValues) { int n = (k + j) % data.size(); if (isTraceEnabled()) { trace(String.format("%s:%s", new String(originalForm1, Charsets.UTF_8), new String(originalForm2, Charsets.UTF_8)), n); } data.set(n, data.get(n) + w); } } } }