Tabnine Logo
DoubleMatrix.columnIndices
Code IndexAdd Tabnine to your IDE (free)

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

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

origin: de.jungblut.math/tjungblut-math

/**
 * Creates a new matrix with the given vector into the first column and the
 * other matrix to the other columns. This is usually used in machine learning
 * algorithms that add a bias on the zero-index column.
 * 
 * @param first the new first column.
 * @param otherMatrix the other matrix to set on from the second column.
 */
public DenseDoubleMatrix(DenseDoubleVector first, DoubleMatrix otherMatrix) {
 this(otherMatrix.getRowCount(), otherMatrix.getColumnCount() + 1);
 // copy the first column
 System.arraycopy(first.toArray(), 0, matrix, 0, first.getDimension());
 int offset = first.getDimension();
 for (int col : otherMatrix.columnIndices()) {
  double[] clv = otherMatrix.getColumnVector(col).toArray();
  System.arraycopy(clv, 0, matrix, offset, clv.length);
  offset += clv.length;
 }
}
origin: de.jungblut.math/tjungblut-math

@Override
public DoubleMatrix divide(DoubleMatrix other) {
 SparseDoubleRowMatrix m = new SparseDoubleRowMatrix(other);
 for (int row : this.matrix.keys()) {
  Iterator<DoubleVectorElement> iterateNonZero = matrix.get(row)
    .iterateNonZero();
  while (iterateNonZero.hasNext()) {
   DoubleVectorElement e = iterateNonZero.next();
   m.set(row, e.getIndex(),
     get(row, e.getIndex()) / other.get(row, e.getIndex()));
  }
 }
 for (int col : other.columnIndices()) {
  Iterator<DoubleVectorElement> iterateNonZero = other.getColumnVector(col)
    .iterateNonZero();
  while (iterateNonZero.hasNext()) {
   DoubleVectorElement e = iterateNonZero.next();
   m.set(e.getIndex(), col,
     get(e.getIndex(), col) / other.get(e.getIndex(), col));
  }
 }
 return m;
}
origin: de.jungblut.common/thomasjungblut-common

@Override
public DoubleMatrix gradient(DoubleMatrix matrix) {
  DoubleMatrix newInstance = newInstance(matrix);
  if (matrix.isSparse()) {
    // if we have a sparse matrix, it is more efficient to loop over the
    // sparse column vectors
    int[] columnIndices = matrix.columnIndices();
    for (int col : columnIndices) {
      newInstance.setColumnVector(col, gradient(matrix.getColumnVector(col)));
    }
  } 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, gradient(matrix.get(i, j)));
      }
    }
  }
  return newInstance;
}
de.jungblut.mathDoubleMatrixcolumnIndices

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.
  • 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.
  • setRowVector
    Sets the whole row at index rowIndex 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

  • Running tasks concurrently on multiple threads
  • requestLocationUpdates (LocationManager)
  • putExtra (Intent)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • Path (java.nio.file)
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • Top plugins for WebStorm
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