Codota Logo
Vector.value
Code IndexAdd Codota to your IDE (free)

How to use
value
method
in
eu.monnetproject.math.sparse.Vector

Best Java code snippets using eu.monnetproject.math.sparse.Vector.value (Showing top 14 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
OutputStreamWriter o =
  • Codota IconOutputStream out;new OutputStreamWriter(out)
  • Codota IconOutputStream out;String charsetName;new OutputStreamWriter(out, charsetName)
  • Codota IconHttpURLConnection connection;new OutputStreamWriter(connection.getOutputStream())
  • Smart code suggestions by Codota
}
origin: com.github.monnetproject/bliss.sparsemath

@Override
public Double value(int idx) {
  return v.value(idx).doubleValue();
}
origin: com.github.monnetproject/bliss.sparsemath

@Override
public N value(int i, int j) {
  if (arr[i] == null) {
    return using.valueOf(defaultValue);
  } else {
    return arr[i].value(j);
  }
}
origin: com.github.monnetproject/bliss.betalm

public static <M extends Number, N extends Number> double cosSim(Vector<M> vec1, Vector<N> vec2, final StopWordList stopWordList) {
  double ab = 0.0;
  double a2 = 0.0;
  for (int i : vec1.keySet()) {
    if (stopWordList.contains(i)) {
      continue;
    }
    ab += (double) vec2.value(i).doubleValue() * (double) vec1.value(i).doubleValue();
    a2 += (double) vec1.value(i).doubleValue() * (double) vec1.value(i).doubleValue();
  }
  double b2 = 0.0;
  for (int i : vec2.keySet()) {
    if (stopWordList.contains(i)) {
      continue;
    }
    b2 += (double) vec2.value(i).doubleValue() * (double) vec2.value(i).doubleValue();
  }
  return a2 > 0 && b2 > 0 ? ab / Math.sqrt(a2) / Math.sqrt(b2) : 0;
}
origin: com.github.monnetproject/bliss.betalm

  @Override
  public double score(Vector<Integer> vec2) {
    double ab = 0.0;
    if (Double.isNaN(a2)) {
      a2 = 0.0;
      for (int i : vec1.keySet()) {
        if (stopWordList.contains(i)) {
          continue;
        }
        a2 += (double) vec1.value(i).doubleValue() * (double) vec1.value(i).doubleValue();
      }
    }
    double b2 = 0.0;
    for (int i : vec2.keySet()) {
      if (stopWordList.contains(i)) {
        continue;
      }
      ab += (double) vec2.value(i).doubleValue() * (double) vec1.value(i).doubleValue();
      b2 += (double) vec2.value(i).doubleValue() * (double) vec2.value(i).doubleValue();
    }
    return a2 > 0 && b2 > 0 ? ab / Math.sqrt(a2) / Math.sqrt(b2) : 0;
  }
};
origin: com.github.monnetproject/bliss.sparsemath

@Override
public boolean isSymmetric() {
  if (m != n) {
    return false;
  }
  for (int i = 0; i < m; i++) {
    if (arr[i] == null) {
      continue;
    }
    for (Map.Entry<Integer, N> e : arr[i].entrySet()) {
      if (arr[e.getKey()] == null) {
        return false;
      }
      if (arr[e.getKey()].value(i).doubleValue() != e.getValue().doubleValue()) {
        return false;
      }
    }
  }
  return true;
}
origin: com.github.monnetproject/bliss.betalm

public static double cosSim(double[] vec1, Vector<Integer> vec2, final StopWordList stopWordList) {
  double ab = 0.0;
  double a2 = 0.0;
  double b2 = 0.0;
  for (int i : vec2.keySet()) {
    if (stopWordList.contains(i)) {
      continue;
    }
    ab += (double) vec2.value(i).doubleValue() * vec1[i];
    b2 += (double) vec2.value(i).doubleValue() * (double) vec2.value(i).doubleValue();
  }
  for (int i = 0; i < vec1.length; i++) {
    if (stopWordList.contains(i)) {
      continue;
    }
    a2 += vec1[i] * vec1[i];
  }
  return a2 > 0 && b2 > 0 ? ab / Math.sqrt(a2) / Math.sqrt(b2) : 0;
}
private static final double KLD_NEG_COST = -5;
origin: com.github.monnetproject/bliss.sparsemath

@Override
public void add(int i, int j, N v) {
  if (arr[i] == null) {
    arr[i] = using.make(n, defaultValue);
    arr[i].put(j, v.doubleValue() + defaultValue);
  } else {
    arr[i].put(j, arr[i].value(j).doubleValue() + v.doubleValue());
  }
}
origin: com.github.monnetproject/bliss.sparsemath

@Override
public void add(int i, int j, int v) {
  if (arr[i] == null) {
    arr[i] = using.make(n, defaultValue);
    arr[i].put(j, using.valueOf(v + defaultValue));
  } else {
    arr[i].put(j, arr[i].value(j).intValue() + v);
  }
}
origin: com.github.monnetproject/bliss.sparsemath

@Override
public void add(int i, int j, double v) {
  if (arr[i] == null) {
    arr[i] = using.make(n, defaultValue);
    arr[i].put(j, using.valueOf(v + defaultValue));
  } else {
    arr[i].put(j, arr[i].value(j).doubleValue() + v);
  }
}
origin: com.github.monnetproject/bliss.betalm

public static double kullbackLeiblerDivergence(Vector<Integer> vec1, Vector<Integer> vec2, final StopWordList stopWordList) {
  final double N1 = vec1.sum(), N2 = vec2.sum();
  double kld = 0.0;
  for (Map.Entry<Integer, Integer> e : vec1.entrySet()) {
    if (stopWordList.contains(e.getKey())) {
      continue;
    }
    final int tfj = vec2.value(e.getKey()).intValue();
    if (tfj != 0) {
      kld += (double) e.getValue() / N1 * Math.max(KLD_NEG_COST, Math.log(N2 / N1 * e.getValue() * tfj));
    } else {
      kld += (double) e.getValue() / N1 * KLD_NEG_COST;
    }
  }
  return kld;
}
origin: com.github.monnetproject/bliss.betalm

public static Vector<Integer> filter(final IntSet salients, final Vector<Integer> source) {
  final SparseIntArray filtered = new SparseIntArray(source.length());
  for (int i : salients) {
    filtered.add(i, source.value(i));
  }
  return filtered;
}

origin: com.github.monnetproject/bliss.betalm

  continue;
final double v1i = vec1.value(i).doubleValue();// / v1sum;
final double v2i = vec2.value(i).doubleValue();// / v2sum;
ab += v2i * v1i - v2sum * mu.doubleValue(i) * v1i - v1sum * mu.doubleValue(i) * v2i;
a2 += v1i * v1i - 2 * v1sum * mu.doubleValue(i) * v1i;
    continue;
  final double v2i = vec1.value(i).doubleValue();// / v2sum;
origin: com.github.monnetproject/bliss.betalm

  continue;
final double v1i = vec1.value(i).doubleValue();// / v1sum;
final double v2i = vec2.value(i).doubleValue();// / v2sum;
ab += v2i * v1i - v2sum * mu.doubleValue(i) * v1i - v1sum * mu.doubleValue(i) * v2i;
a2 += v1i * v1i - 2 * v1sum * mu.doubleValue(i) * v1i;
  continue;
final double v2i = vec2.value(i).doubleValue();// / v2sum;
if (!vec1.containsKey(i)) {
  ab -= v1sum * mu.doubleValue(i) * v2i;
origin: com.github.monnetproject/bliss.betalm

public static IntSet mostSalient(final File reference, final File corpus, int W, int topN, SourceType sourceType) throws IOException {
  final PrecomputedValues precomp1 = PrecomputedValues.precompute(reference, W, SourceType.SIMPLE);
  final PrecomputedValues precomp2 = PrecomputedValues.precompute(corpus, W, sourceType);
  final double[] salience = new double[W];
  final IntRBTreeSet topNWords = new IntRBTreeSet(new IntComparator() {
    @Override
    public int compare(int i, int i1) {
      return salience[i] < salience[i1] ? -1 : (salience[i] > salience[i1] ? 1 : i - i1);
    }
    @Override
    public int compare(Integer o1, Integer o2) {
      return compare(o1.intValue(), o2.intValue());
    }
  });
  for (int w = 0; w < W; w++) {
    final double val = precomp1.mu.value(w);
    final Double val2 = precomp2.mu.value(w);
    if (val != 0.0 && val2 != 0.0) {
      salience[w] = val / val2;
      if (topNWords.size() < topN) {
        topNWords.add(w);
      } else if (salience[w] > salience[topNWords.firstInt()]) {
        topNWords.remove(topNWords.first());
        topNWords.add(w);
      }
    }
  }
  return topNWords;
}
eu.monnetproject.math.sparseVectorvalue

Javadoc

The value at the given index. Note the default value will be returned at sparse indexes

Popular methods of Vector

  • entrySet
    Get all non-sparse values in the array
  • sum
    Get the sum of all the values in this vector
  • add
    Add a vector to this vector. This will automatically remove an element if it results in the value at
  • containsKey
    Is the following index in range and with non-default value
  • divide
    Divide a value by a value in the sparse array. This will automatically remove an element if it resul
  • doubleValue
    The value at the given index. Note the default value will be returned at sparse indexes
  • keySet
    Get the set of indices with non-default value
  • length
    Get the length (i.e., number of sparse and non-sparse values) of the array
  • size
    Get the number of non-sparse values in the array
  • clone
    Creates a copy of this vector
  • defaultValue
    Get the default value of the array
  • factory
    The factory for making more of this type of vector
  • defaultValue,
  • factory,
  • innerProduct,
  • intValue,
  • multiply,
  • norm,
  • outerProduct,
  • put,
  • sub

Popular in Java

  • Start an intent from android
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • addToBackStack (FragmentTransaction)
  • compareTo (BigDecimal)
    Compares this BigDecimal with the specified BigDecimal. Two BigDecimal objects that are equal in val
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • DecimalFormat (java.text)
    DecimalFormat is a concrete subclass ofNumberFormat that formats decimal numbers. It has a variety o
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • Locale (java.util)
    A Locale object represents a specific geographical, political, or cultural region. An operation that
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now