Codota Logo
DoubleMatrix.setRowVector
Code IndexAdd Codota to your IDE (free)

How to use
setRowVector
method
in
de.jungblut.math.DoubleMatrix

Best Java code snippets using de.jungblut.math.DoubleMatrix.setRowVector (Showing top 7 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Gson g =
  • Codota Iconnew Gson()
  • Codota IconGsonBuilder gsonBuilder;gsonBuilder.create()
  • Codota Iconnew GsonBuilder().create()
  • Smart code suggestions by Codota
}
origin: de.jungblut.common/thomasjungblut-common

@Override
public DoubleMatrix apply(DoubleMatrix matrix) {
  DoubleMatrix dm = newInstance(matrix);
  for (int row = 0; row < matrix.getRowCount(); row++) {
    DoubleVector apply = apply(matrix.getRowVector(row));
    if (apply.getLength() != 0) {
      dm.setRowVector(row, apply);
    }
  }
  return dm;
}
origin: de.jungblut.math/tjungblut-math

@Override
public DoubleMatrix subtract(DoubleVector vec) {
 DoubleMatrix result = new SparseDoubleRowMatrix(this.getRowCount(),
   this.getColumnCount());
 for (int row : this.matrix.keys()) {
  SparseDoubleVector rowVec = matrix.get(row);
  result.setRowVector(row, rowVec.subtract(vec.get(row)));
 }
 return result;
}
origin: de.jungblut.common/thomasjungblut-common

final int numHiddenStates = beta.getColumnCount();
beta.setRowVector(features.length - 1,
    DenseDoubleVector.ones(numHiddenStates));
origin: de.jungblut.common/thomasjungblut-common

transitionProbabilityMatrix.setRowVector(rowIndex,
    DenseDoubleVector.ones(numHiddenStates));
emissionProbabilityMatrix.setRowVector(rowIndex,
    DenseDoubleVector.ones(numVisibleStates));
origin: de.jungblut.common/thomasjungblut-common

private static void normalize(DoubleVector hiddenPriorProbability,
               DoubleMatrix transitionProbabilityMatrix,
               DoubleMatrix emissionProbabilitiyMatrix, boolean log) {
  double sum = hiddenPriorProbability.sum();
  if (sum != 0d) {
    for (int i = 0; i < hiddenPriorProbability.getDimension(); i++) {
      hiddenPriorProbability.set(i, hiddenPriorProbability.get(i) / sum);
    }
  }
  for (int row = 0; row < transitionProbabilityMatrix.getRowCount(); row++) {
    // note that we are using row vectors here, because dense matrices give us
    // the underlying array wrapped by the vector object so we can directly
    // mutate the values beneath
    DoubleVector rowVector = transitionProbabilityMatrix.getRowVector(row);
    rowVector = rowVector.divide(rowVector.sum());
    if (log) {
      rowVector = rowVector.log();
    }
    transitionProbabilityMatrix.setRowVector(row, rowVector);
    rowVector = emissionProbabilitiyMatrix.getRowVector(row);
    rowVector = rowVector.divide(rowVector.sum());
    if (log) {
      rowVector = rowVector.log();
    }
    emissionProbabilitiyMatrix.setRowVector(row, rowVector);
  }
}
origin: de.jungblut.common/thomasjungblut-common

@Override
public DoubleMatrix apply(DoubleMatrix matrix) {
  DoubleMatrix newInstance = newInstance(matrix);
  if (matrix.isSparse()) {
    // if we have a sparse matrix, it is more efficient to loop over the
    // sparse row vectors
    int[] rows = matrix.rowIndices();
    for (int row : rows) {
      DoubleVector rowVector = matrix.getRowVector(row);
      if (rowVector.getLength() > 0) {
        DoubleVector apply = apply(rowVector);
        newInstance.setRowVector(row, apply);
      }
    }
  } else {
    // on dense matrices we can be faster by directly looping over the items
    for (int i = 0; i < matrix.getRowCount(); i++) {
      for (int j = 0; j < matrix.getColumnCount(); j++) {
        newInstance.set(i, j, apply(matrix.get(i, j)));
      }
    }
  }
  return newInstance;
}
origin: de.jungblut.common/thomasjungblut-common

  vec.set(0, bestLabel);
outcome.setRowVector(position, vec);
bestLabel = backpointers[position][bestLabel];
de.jungblut.mathDoubleMatrixsetRowVector

Javadoc

Sets the whole row at index rowIndex with the given vector.

Popular methods of DoubleMatrix

  • get
    Get a specific value of the matrix.
  • getColumnCount
    Returns the number of columns in the matrix. Always a constant time operation.
  • getRowVector
    Get a single row of the matrix as a vector.
  • set
    Sets the value at the given row and column index.
  • columnIndices
  • getColumnVector
    Get a whole column of the matrix as vector.
  • getRowCount
    Returns the number of rows in this matrix. Always a constant time operation.
  • setColumnVector
    Sets a whole column at index col with the given vector.
  • add
    Adds the elements in the given matrix to the elements in this matrix.
  • deepCopy
  • divide
    Divides each element in a column by the related element in the given vector.
  • isSparse
  • divide,
  • isSparse,
  • multiply,
  • multiplyElementWise,
  • multiplyVectorRow,
  • pow,
  • rowIndices,
  • slice,
  • subtract

Popular in Java

  • Reading from database using SQL prepared statement
  • runOnUiThread (Activity)
  • orElseThrow (Optional)
  • onCreateOptionsMenu (Activity)
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • FileInputStream (java.io)
    A FileInputStream obtains input bytes from a file in a file system. What files are available depends
  • FileWriter (java.io)
    Convenience class for writing character files. The constructors of this class assume that the defaul
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • Timer (java.util)
    A facility for threads to schedule tasks for future execution in a background thread. Tasks may be s
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