Tabnine Logo
DoubleMatrix.setRowVector
Code IndexAdd Tabnine 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)

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

  • Finding current android device location
  • findViewById (Activity)
  • onCreateOptionsMenu (Activity)
  • addToBackStack (FragmentTransaction)
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • Color (java.awt)
    The Color class is used to encapsulate colors in the default sRGB color space or colors in arbitrary
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • Time (java.sql)
    Java representation of an SQL TIME value. Provides utilities to format and parse the time's represen
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now