Tabnine Logo
SparseDoubleMatrix1D
Code IndexAdd Tabnine to your IDE (free)

How to use
SparseDoubleMatrix1D
in
cern.colt.matrix.impl

Best Java code snippets using cern.colt.matrix.impl.SparseDoubleMatrix1D (Showing top 20 results out of 315)

origin: com.blazegraph/colt

/**
 * Construct and returns a new 1-d matrix <i>of the corresponding dynamic type</i>, entirelly independent of the receiver.
 * For example, if the receiver is an instance of type <tt>DenseDoubleMatrix2D</tt> the new matrix must be of type <tt>DenseDoubleMatrix1D</tt>,
 * if the receiver is an instance of type <tt>SparseDoubleMatrix2D</tt> the new matrix must be of type <tt>SparseDoubleMatrix1D</tt>, etc.
 *
 * @param size the number of cells the matrix shall have.
 * @return  a new matrix of the corresponding dynamic type.
 */
public DoubleMatrix1D like1D(int size) {
  return new SparseDoubleMatrix1D(size);
}
/**
origin: blazegraph/database

/**
 * Constructs a matrix with a copy of the given values.
 * The values are copied. So subsequent changes in <tt>values</tt> are not reflected in the matrix, and vice-versa.
 *
 * @param values The values to be filled into the new matrix.
 */
public SparseDoubleMatrix1D(double[] values) {
  this(values.length);
  assign(values);
}
/**
origin: blazegraph/database

/**
 * Constructs a matrix view with a given number of parameters.
 * 
 * @param size the number of cells the matrix shall have.
 * @param elements the cells.
 * @param offset the index of the first element.
 * @param stride the number of indexes between any two elements, i.e. <tt>index(i+1)-index(i)</tt>.
 * @throws IllegalArgumentException if <tt>size<0</tt>.
 */
protected SparseDoubleMatrix1D(int size, AbstractIntDoubleMap elements, int offset, int stride) {
  setUp(size,offset,stride);
  this.elements = elements;
  this.isNoView = false;
}
/**
origin: edu.illinois.cs.cogcomp/DatalessClassification

protected double normQuick(SparseDoubleMatrix1D v) {
  IntArrayList indexList = new IntArrayList();
  DoubleArrayList valueList = new DoubleArrayList();
  v.getNonZeros(indexList, valueList);
  double norm = 0.0;
  for (int i = 0; i < valueList.size(); ++i) {
    norm += valueList.get(i) * valueList.get(i);
  }
  return norm;
}
 
origin: blazegraph/database

/**
 * Construct and returns a new 1-d matrix <i>of the corresponding dynamic type</i>, entirelly independent of the receiver.
 * For example, if the receiver is an instance of type <tt>DenseDoubleMatrix2D</tt> the new matrix must be of type <tt>DenseDoubleMatrix1D</tt>,
 * if the receiver is an instance of type <tt>SparseDoubleMatrix2D</tt> the new matrix must be of type <tt>SparseDoubleMatrix1D</tt>, etc.
 *
 * @param size the number of cells the matrix shall have.
 * @return  a new matrix of the corresponding dynamic type.
 */
public DoubleMatrix1D like1D(int size) {
  return new SparseDoubleMatrix1D(size);
}
/**
origin: com.blazegraph/colt

/**
 * Constructs a matrix view with a given number of parameters.
 * 
 * @param size the number of cells the matrix shall have.
 * @param elements the cells.
 * @param offset the index of the first element.
 * @param stride the number of indexes between any two elements, i.e. <tt>index(i+1)-index(i)</tt>.
 * @throws IllegalArgumentException if <tt>size<0</tt>.
 */
protected SparseDoubleMatrix1D(int size, AbstractIntDoubleMap elements, int offset, int stride) {
  setUp(size,offset,stride);
  this.elements = elements;
  this.isNoView = false;
}
/**
origin: com.blazegraph/colt

/**
 * Constructs a matrix with a copy of the given values.
 * The values are copied. So subsequent changes in <tt>values</tt> are not reflected in the matrix, and vice-versa.
 *
 * @param values The values to be filled into the new matrix.
 */
public SparseDoubleMatrix1D(double[] values) {
  this(values.length);
  assign(values);
}
/**
origin: blazegraph/database

/**
 * Construct and returns a new 1-d matrix <i>of the corresponding dynamic type</i>, entirelly independent of the receiver.
 * For example, if the receiver is an instance of type <tt>DenseDoubleMatrix2D</tt> the new matrix must be of type <tt>DenseDoubleMatrix1D</tt>,
 * if the receiver is an instance of type <tt>SparseDoubleMatrix2D</tt> the new matrix must be of type <tt>SparseDoubleMatrix1D</tt>, etc.
 *
 * @param size the number of cells the matrix shall have.
 * @return  a new matrix of the corresponding dynamic type.
 */
public DoubleMatrix1D like1D(int size) {
  return new SparseDoubleMatrix1D(size);
}
/**
origin: blazegraph/database

/**
 * Constructs a matrix with a given number of parameters.
 * All entries are initially <tt>0</tt>.
 * For details related to memory usage see {@link cern.colt.map.OpenIntDoubleHashMap}.
 * 
 * @param size the number of cells the matrix shall have.
 * @param initialCapacity   the initial capacity of the hash map.
 *                          If not known, set <tt>initialCapacity=0</tt> or small.     
 * @param minLoadFactor        the minimum load factor of the hash map.
 * @param maxLoadFactor        the maximum load factor of the hash map.
 * @throws    IllegalArgumentException if <tt>initialCapacity < 0 || (minLoadFactor < 0.0 || minLoadFactor >= 1.0) || (maxLoadFactor <= 0.0 || maxLoadFactor >= 1.0) || (minLoadFactor >= maxLoadFactor)</tt>.
 * @throws IllegalArgumentException if <tt>size<0</tt>.
 */
public SparseDoubleMatrix1D(int size, int initialCapacity, double minLoadFactor, double maxLoadFactor) {
  setUp(size);
  this.elements = new OpenIntDoubleHashMap(initialCapacity, minLoadFactor, maxLoadFactor);
}
/**
origin: com.blazegraph/colt

/**
 * Construct and returns a new 1-d matrix <i>of the corresponding dynamic type</i>, entirelly independent of the receiver.
 * For example, if the receiver is an instance of type <tt>DenseDoubleMatrix2D</tt> the new matrix must be of type <tt>DenseDoubleMatrix1D</tt>,
 * if the receiver is an instance of type <tt>SparseDoubleMatrix2D</tt> the new matrix must be of type <tt>SparseDoubleMatrix1D</tt>, etc.
 *
 * @param size the number of cells the matrix shall have.
 * @return  a new matrix of the corresponding dynamic type.
 */
public DoubleMatrix1D like1D(int size) {
  return new SparseDoubleMatrix1D(size);
}
/**
origin: com.blazegraph/colt

/**
 * Constructs a matrix with a given number of parameters.
 * All entries are initially <tt>0</tt>.
 * For details related to memory usage see {@link cern.colt.map.OpenIntDoubleHashMap}.
 * 
 * @param size the number of cells the matrix shall have.
 * @param initialCapacity   the initial capacity of the hash map.
 *                          If not known, set <tt>initialCapacity=0</tt> or small.     
 * @param minLoadFactor        the minimum load factor of the hash map.
 * @param maxLoadFactor        the maximum load factor of the hash map.
 * @throws    IllegalArgumentException if <tt>initialCapacity < 0 || (minLoadFactor < 0.0 || minLoadFactor >= 1.0) || (maxLoadFactor <= 0.0 || maxLoadFactor >= 1.0) || (minLoadFactor >= maxLoadFactor)</tt>.
 * @throws IllegalArgumentException if <tt>size<0</tt>.
 */
public SparseDoubleMatrix1D(int size, int initialCapacity, double minLoadFactor, double maxLoadFactor) {
  setUp(size);
  this.elements = new OpenIntDoubleHashMap(initialCapacity, minLoadFactor, maxLoadFactor);
}
/**
origin: com.blazegraph/colt

/**
 * Construct and returns a new 1-d matrix <i>of the corresponding dynamic type</i>, entirelly independent of the receiver.
 * For example, if the receiver is an instance of type <tt>DenseDoubleMatrix2D</tt> the new matrix must be of type <tt>DenseDoubleMatrix1D</tt>,
 * if the receiver is an instance of type <tt>SparseDoubleMatrix2D</tt> the new matrix must be of type <tt>SparseDoubleMatrix1D</tt>, etc.
 *
 * @param size the number of cells the matrix shall have.
 * @return  a new matrix of the corresponding dynamic type.
 */
public DoubleMatrix1D like1D(int size) {
  return new SparseDoubleMatrix1D(size);
}
/**
origin: com.blazegraph/colt

/**
 * Construct and returns a new empty matrix <i>of the same dynamic type</i> as the receiver, having the specified size.
 * For example, if the receiver is an instance of type <tt>DenseDoubleMatrix1D</tt> the new matrix must also be of type <tt>DenseDoubleMatrix1D</tt>,
 * if the receiver is an instance of type <tt>SparseDoubleMatrix1D</tt> the new matrix must also be of type <tt>SparseDoubleMatrix1D</tt>, etc.
 * In general, the new matrix should have internal parametrization as similar as possible.
 *
 * @param size the number of cell the matrix shall have.
 * @return  a new empty matrix of the same dynamic type.
 */
public DoubleMatrix1D like(int size) {
  return new SparseDoubleMatrix1D(size);
}
/**
origin: com.blazegraph/colt

/**
 * Construct and returns a new empty matrix <i>of the same dynamic type</i> as the receiver, having the specified size.
 * For example, if the receiver is an instance of type <tt>DenseDoubleMatrix1D</tt> the new matrix must also be of type <tt>DenseDoubleMatrix1D</tt>,
 * if the receiver is an instance of type <tt>SparseDoubleMatrix1D</tt> the new matrix must also be of type <tt>SparseDoubleMatrix1D</tt>, etc.
 * In general, the new matrix should have internal parametrization as similar as possible.
 *
 * @param size the number of cell the matrix shall have.
 * @return  a new empty matrix of the same dynamic type.
 */
public DoubleMatrix1D like(int size) {
  return new SparseDoubleMatrix1D(size);
}
/**
origin: blazegraph/database

/**
 * Construct and returns a new empty matrix <i>of the same dynamic type</i> as the receiver, having the specified size.
 * For example, if the receiver is an instance of type <tt>DenseDoubleMatrix1D</tt> the new matrix must also be of type <tt>DenseDoubleMatrix1D</tt>,
 * if the receiver is an instance of type <tt>SparseDoubleMatrix1D</tt> the new matrix must also be of type <tt>SparseDoubleMatrix1D</tt>, etc.
 * In general, the new matrix should have internal parametrization as similar as possible.
 *
 * @param size the number of cell the matrix shall have.
 * @return  a new empty matrix of the same dynamic type.
 */
public DoubleMatrix1D like(int size) {
  return new SparseDoubleMatrix1D(size);
}
/**
origin: blazegraph/database

/**
 * Construct and returns a new 1-d matrix <i>of the corresponding dynamic type</i>, entirelly independent of the receiver.
 * For example, if the receiver is an instance of type <tt>DenseDoubleMatrix2D</tt> the new matrix must be of type <tt>DenseDoubleMatrix1D</tt>,
 * if the receiver is an instance of type <tt>SparseDoubleMatrix2D</tt> the new matrix must be of type <tt>SparseDoubleMatrix1D</tt>, etc.
 *
 * @param size the number of cells the matrix shall have.
 * @return  a new matrix of the corresponding dynamic type.
 */
public DoubleMatrix1D like1D(int size) {
  return new SparseDoubleMatrix1D(size);
}
protected void remove(int row, int index) {
origin: blazegraph/database

/**
 * Construct and returns a new 1-d matrix <i>of the corresponding dynamic type</i>, entirelly independent of the receiver.
 * For example, if the receiver is an instance of type <tt>DenseDoubleMatrix2D</tt> the new matrix must be of type <tt>DenseDoubleMatrix1D</tt>,
 * if the receiver is an instance of type <tt>SparseDoubleMatrix2D</tt> the new matrix must be of type <tt>SparseDoubleMatrix1D</tt>, etc.
 *
 * @param size the number of cells the matrix shall have.
 * @return  a new matrix of the corresponding dynamic type.
 */
public DoubleMatrix1D like1D(int size) {
  return new SparseDoubleMatrix1D(size);
}
/**
origin: blazegraph/database

/**
 * Construct and returns a new 1-d matrix <i>of the corresponding dynamic type</i>, entirelly independent of the receiver.
 * For example, if the receiver is an instance of type <tt>DenseDoubleMatrix2D</tt> the new matrix must be of type <tt>DenseDoubleMatrix1D</tt>,
 * if the receiver is an instance of type <tt>SparseDoubleMatrix2D</tt> the new matrix must be of type <tt>SparseDoubleMatrix1D</tt>, etc.
 *
 * @param size the number of cells the matrix shall have.
 * @return  a new matrix of the corresponding dynamic type.
 */
public DoubleMatrix1D like1D(int size) {
  return new SparseDoubleMatrix1D(size);
}
/**
origin: com.blazegraph/colt

/**
 * Construct and returns a new 1-d matrix <i>of the corresponding dynamic type</i>, entirelly independent of the receiver.
 * For example, if the receiver is an instance of type <tt>DenseDoubleMatrix2D</tt> the new matrix must be of type <tt>DenseDoubleMatrix1D</tt>,
 * if the receiver is an instance of type <tt>SparseDoubleMatrix2D</tt> the new matrix must be of type <tt>SparseDoubleMatrix1D</tt>, etc.
 *
 * @param size the number of cells the matrix shall have.
 * @return  a new matrix of the corresponding dynamic type.
 */
public DoubleMatrix1D like1D(int size) {
  return new SparseDoubleMatrix1D(size);
}
/**
origin: com.blazegraph/colt

/**
 * Construct and returns a new 1-d matrix <i>of the corresponding dynamic type</i>, entirelly independent of the receiver.
 * For example, if the receiver is an instance of type <tt>DenseDoubleMatrix2D</tt> the new matrix must be of type <tt>DenseDoubleMatrix1D</tt>,
 * if the receiver is an instance of type <tt>SparseDoubleMatrix2D</tt> the new matrix must be of type <tt>SparseDoubleMatrix1D</tt>, etc.
 *
 * @param size the number of cells the matrix shall have.
 * @return  a new matrix of the corresponding dynamic type.
 */
public DoubleMatrix1D like1D(int size) {
  return new SparseDoubleMatrix1D(size);
}
protected void remove(int row, int index) {
cern.colt.matrix.implSparseDoubleMatrix1D

Javadoc

Sparse hashed 1-d matrix (aka vector) holding double elements. First see the package summary and javadoc tree view to get the broad picture.

Implementation:

Note that this implementation is not synchronized. Uses a cern.colt.map.OpenIntDoubleHashMap, which is a compact and performant hashing technique.

Memory requirements:

Cells that

  • are never set to non-zero values do not use any memory.
  • switch from zero to non-zero state do use memory.
  • switch back from non-zero to zero state also do use memory. However, their memory is automatically reclaimed from time to time. It can also manually be reclaimed by calling #trimToSize().

worst case: memory [bytes] = (1/minLoadFactor) * nonZeros * 13.
best case: memory [bytes] = (1/maxLoadFactor) * nonZeros * 13.
Where nonZeros = cardinality() is the number of non-zero cells. Thus, a 1000000 matrix with minLoadFactor=0.25 and maxLoadFactor=0.5 and 1000000 non-zero cells consumes between 25 MB and 50 MB. The same 1000000 matrix with 1000 non-zero cells consumes between 25 and 50 KB.

Time complexity:

This class offers expected time complexity O(1) (i.e. constant time) for the basic operations get, getQuick, set, setQuick and size assuming the hash function disperses the elements properly among the buckets. Otherwise, pathological cases, although highly improbable, can occur, degrading performance to O(N) in the worst case. As such this sparse class is expected to have no worse time complexity than its dense counterpart DenseDoubleMatrix1D. However, constant factors are considerably larger.

Most used methods

  • <init>
    Constructs a matrix with a copy of the given values. The values are copied. So subsequent changes in
  • assign
  • getNonZeros
  • setUp

Popular in Java

  • Running tasks concurrently on multiple threads
  • getSharedPreferences (Context)
  • findViewById (Activity)
  • getSystemService (Context)
  • Kernel (java.awt.image)
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • JFrame (javax.swing)
  • Option (scala)
  • 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