/** * Returns the matrix cell value at coordinate <tt>[row,column]</tt>. * * <p>Provided with invalid parameters this method may return invalid objects without throwing any exception. * <b>You should only use this method when you are absolutely sure that the coordinate is within bounds.</b> * Precondition (unchecked): <tt>0 <= column < columns() && 0 <= row < rows()</tt>. * * @param row the index of the row-coordinate. * @param column the index of the column-coordinate. * @return the value at the specified coordinate. */ public double getQuick(int row, int column) { int k = indexes.binarySearchFromTo(column,starts[row],starts[row+1]-1); double v = 0; if (k>=0) v = values.getQuick(k); return v; } protected void insert(int row, int column, int index, double value) {
/** * Returns the matrix cell value at coordinate <tt>[row,column]</tt>. * * <p>Provided with invalid parameters this method may return invalid objects without throwing any exception. * <b>You should only use this method when you are absolutely sure that the coordinate is within bounds.</b> * Precondition (unchecked): <tt>0 <= column < columns() && 0 <= row < rows()</tt>. * * @param row the index of the row-coordinate. * @param column the index of the column-coordinate. * @return the value at the specified coordinate. */ public double getQuick(int row, int column) { int k = indexes.binarySearchFromTo(column,starts[row],starts[row+1]-1); double v = 0; if (k>=0) v = values.getQuick(k); return v; } protected void insert(int row, int column, int index, double value) {
/** * Sets the matrix cell at coordinate <tt>[row,column]</tt> to the specified value. * * <p>Provided with invalid parameters this method may access illegal indexes without throwing any exception. * <b>You should only use this method when you are absolutely sure that the coordinate is within bounds.</b> * Precondition (unchecked): <tt>0 <= column < columns() && 0 <= row < rows()</tt>. * * @param row the index of the row-coordinate. * @param column the index of the column-coordinate. * @param value the value to be filled into the specified cell. */ public void setQuick(int row, int column, double value) { int k = indexes.binarySearchFromTo(column,starts[row],starts[row+1]-1); if (k>=0) { // found if (value==0) remove(row,k); else values.setQuick(k,value); return; } if (value!=0) { k = -k-1; insert(row,column,k,value); } } public void trimToSize() {
/** * Sets the matrix cell at coordinate <tt>[row,column]</tt> to the specified value. * * <p>Provided with invalid parameters this method may access illegal indexes without throwing any exception. * <b>You should only use this method when you are absolutely sure that the coordinate is within bounds.</b> * Precondition (unchecked): <tt>0 <= column < columns() && 0 <= row < rows()</tt>. * * @param row the index of the row-coordinate. * @param column the index of the column-coordinate. * @param value the value to be filled into the specified cell. */ public void setQuick(int row, int column, double value) { int k = indexes.binarySearchFromTo(column,starts[row],starts[row+1]-1); if (k>=0) { // found if (value==0) remove(row,k); else values.setQuick(k,value); return; } if (value!=0) { k = -k-1; insert(row,column,k,value); } } public void trimToSize() {
cern.colt.Timer timer = new cern.colt.Timer().start(); for (int i=size; --i>=0; ) { int k = list.binarySearchFromTo(val,0,values.length-1); System.out.println(list+", "+val+" --> "+k); sum+=k;
cern.colt.Timer timer = new cern.colt.Timer().start(); for (int i=size; --i>=0; ) { int k = list.binarySearchFromTo(val,0,values.length-1); System.out.println(list+", "+val+" --> "+k); sum+=k;
if (sortedList.binarySearchFromTo(theElements[i], 0, limit) >= 0) theElements[j++]=theElements[i];
if (sortedList.binarySearchFromTo(theElements[i], 0, limit) >= 0) theElements[j++]=theElements[i];
if (sortedList.binarySearchFromTo(theElements[i], 0, limit) >= 0) theElements[j++] = theElements[i];
if (sortedList.binarySearchFromTo(theElements[i], 0, limit) < 0) theElements[j++]=theElements[i];
if (sortedList.binarySearchFromTo(theElements[i], 0, limit) < 0) theElements[j++]=theElements[i];
if (sortedList.binarySearchFromTo(theElements[i], 0, limit) < 0) theElements[j++] = theElements[i];