/** * Returns the number of cells having non-zero values; ignores tolerance. */ public int cardinality() { int cardinality = 0; for (int i=size; --i >= 0;) { if (getQuick(i) != null) cardinality++; } return cardinality; } /**
/** * Returns the number of cells having non-zero values; ignores tolerance. */ public int cardinality() { int cardinality = 0; for (int i=size; --i >= 0;) { if (getQuick(i) != null) cardinality++; } return cardinality; } /**
public int compare(int a, int b) { Comparable av = (Comparable) (splitters[a]); Comparable bv = (Comparable) (columnView.getQuick(g[b])); int r = av.compareTo(bv); return r<0 ? -1 : (r==0 ? 0 : 1); } };
/** Fills the cell values into the specified 1-dimensional array. The values are copied. So subsequent changes in <tt>values</tt> are not reflected in the matrix, and vice-versa. After this call returns the array <tt>values</tt> has the form <br> <tt>for (int i=0; i < size(); i++) values[i] = get(i);</tt> @throws IllegalArgumentException if <tt>values.length < size()</tt>. */ public void toArray(Object[] values) { if (values.length < size) throw new IllegalArgumentException("values too small"); for (int i=size; --i >= 0; ) { values[i] = getQuick(i); } } /**
public int compare(int a, int b) { Comparable av = (Comparable) (splitters[a]); Comparable bv = (Comparable) (columnView.getQuick(g[b])); int r = av.compareTo(bv); return r<0 ? -1 : (r==0 ? 0 : 1); } };
/** * Returns the matrix cell value at coordinate <tt>index</tt>. * * @param index the index of the cell. * @return the value of the specified cell. * @throws IndexOutOfBoundsException if <tt>index<0 || index>=size()</tt>. */ public Object get(int index) { if (index<0 || index>=size) checkIndex(index); return getQuick(index); } /**
/** * Returns the matrix cell value at coordinate <tt>index</tt>. * * @param index the index of the cell. * @return the value of the specified cell. * @throws IndexOutOfBoundsException if <tt>index<0 || index>=size()</tt>. */ public Object get(int index) { if (index<0 || index>=size) checkIndex(index); return getQuick(index); } /**
/** Swaps each element <tt>this[i]</tt> with <tt>other[i]</tt>. @throws IllegalArgumentException if <tt>size() != other.size()</tt>. */ public void swap(ObjectMatrix1D other) { checkSize(other); for (int i=size; --i >= 0; ) { Object tmp = getQuick(i); setQuick(i, other.getQuick(i)); other.setQuick(i, tmp); } return; } /**
/** Swaps each element <tt>this[i]</tt> with <tt>other[i]</tt>. @throws IllegalArgumentException if <tt>size() != other.size()</tt>. */ public void swap(ObjectMatrix1D other) { checkSize(other); for (int i=size; --i >= 0; ) { Object tmp = getQuick(i); setQuick(i, other.getQuick(i)); other.setQuick(i, tmp); } return; } /**
/** * Replaces all cell values of the receiver with the values of another matrix. * Both matrices must have the same size. * If both matrices share the same cells (as is the case if they are views derived from the same matrix) and intersect in an ambiguous way, then replaces <i>as if</i> using an intermediate auxiliary deep copy of <tt>other</tt>. * * @param other the source matrix to copy from (may be identical to the receiver). * @return <tt>this</tt> (for convenience only). * @throws IllegalArgumentException if <tt>size() != other.size()</tt>. */ public ObjectMatrix1D assign(ObjectMatrix1D other) { if (other==this) return this; checkSize(other); if (haveSharedCells(other)) other = other.copy(); for (int i=size; --i >= 0;) { setQuick(i,other.getQuick(i)); } return this; } /**