/** * Returns the position of the element with the given relative rank within * the (virtual or non-virtual) internal 1-dimensional array. You may want * to override this method for performance. * * @param rank * the rank of the element. */ public long index(int rank) { return _offset(_rank(rank)); }
/** * Checks whether indexes are legal and throws an exception, if necessary. * * @throws IndexOutOfBoundsException * if <tt>! (0 <= indexes[i] < size())</tt> for any * i=0..indexes.length()-1. */ protected void checkIndexes(int[] indexes) { for (int i = indexes.length; --i >= 0;) { int index = indexes[i]; if (index < 0 || index >= size) checkIndex(index); } }
/** * Self modifying version of viewPart(). * * @throws IndexOutOfBoundsException * if <tt>index<0 || index+width>size()</tt>. */ protected AbstractMatrix1D vPart(int index, int width) { checkRange(index, width); this.zero += this.stride * index; this.size = width; this.isNoView = false; return this; }
/** * Returns a short string representation describing the shape of the matrix. */ public static String shape(AbstractMatrix1D matrix) { // return "Matrix1D of size="+matrix.size(); // return matrix.size()+" element matrix"; // return "matrix("+matrix.size()+")"; return matrix.size() + " matrix"; }
/** * Sanity check for operations requiring two matrices with the same size. * * @throws IllegalArgumentException * if <tt>size() != B.size()</tt>. */ public void checkSize(AbstractMatrix1D B) { if (size != B.size) throw new IllegalArgumentException("Incompatible sizes: " + toStringShort() + " and " + B.toStringShort()); }
/** * Sets up a matrix with a given number of cells. * * @param size * the number of cells the matrix shall have. * @throws IllegalArgumentException * if <tt>size<0</tt>. */ protected void setUp(int size) { setUp(size, 0, 1); }
/** * Returns a short string representation describing the shape of the matrix. */ public static String shape(AbstractMatrix1D matrix) { // return "Matrix1D of size="+matrix.size(); // return matrix.size()+" element matrix"; // return "matrix("+matrix.size()+")"; return matrix.size() + " matrix"; }
/** * Sanity check for operations requiring two matrices with the same size. * * @throws IllegalArgumentException * if <tt>size() != B.size()</tt>. */ public void checkSize(AbstractMatrix1D B) { if (size != B.size) throw new IllegalArgumentException("Incompatible sizes: " + toStringShort() + " and " + B.toStringShort()); }
/** * Sets up a matrix with a given number of cells. * * @param size * the number of cells the matrix shall have. * @throws IllegalArgumentException * if <tt>size<0</tt>. */ protected void setUp(int size) { setUp(size, 0, 1); }
/** * Returns the position of the element with the given relative rank within * the (virtual or non-virtual) internal 1-dimensional array. You may want * to override this method for performance. * * @param rank * the rank of the element. */ public long index(int rank) { return _offset(_rank(rank)); }
/** * Self modifying version of viewFlip(). What used to be index <tt>0</tt> is * now index <tt>size()-1</tt>, ..., what used to be index <tt>size()-1</tt> * is now index <tt>0</tt>. */ protected AbstractMatrix1D vFlip() { if (size > 0) { this.zero += (this.size() - 1) * this.stride; this.stride = -this.stride; this.isNoView = false; } return this; }
/** * Sanity check for operations requiring an index to be within bounds. * * @throws IndexOutOfBoundsException * if <tt>index < 0 || index >= size()</tt>. */ protected void checkIndex(int index) { if (index < 0 || index >= size) throw new IndexOutOfBoundsException("Attempted to access " + toStringShort() + " at index=" + index); }
/** * Self modifying version of viewPart(). * * @throws IndexOutOfBoundsException * if <tt>index<0 || index+width>size()</tt>. */ protected AbstractMatrix1D vPart(int index, int width) { checkRange(index, width); this.zero += this.stride * index; this.size = width; this.isNoView = false; return this; }
/** * Checks whether indexes are legal and throws an exception, if necessary. * * @throws IndexOutOfBoundsException * if <tt>! (0 <= indexes[i] < size())</tt> for any * i=0..indexes.length()-1. */ protected void checkIndexes(int[] indexes) { for (int i = indexes.length; --i >= 0;) { int index = indexes[i]; if (index < 0 || index >= size) checkIndex(index); } }
/** * Self modifying version of viewFlip(). What used to be index <tt>0</tt> is * now index <tt>size()-1</tt>, ..., what used to be index <tt>size()-1</tt> * is now index <tt>0</tt>. */ protected AbstractMatrix1D vFlip() { if (size > 0) { this.zero += (this.size() - 1) * this.stride; this.stride = -this.stride; this.isNoView = false; } return this; }
/** * Returns the stride of the given dimension (axis, rank). * * @dimension the index of the dimension. * @return the stride in the given dimension. * @throws IllegalArgumentException * if <tt>dimension != 0</tt>. */ protected int stride(int dimension) { if (dimension != 0) throw new IllegalArgumentException("invalid dimension: " + dimension + "used to access" + toStringShort()); return this.stride; }
/** * Returns a string representations of all cells; no alignment considered. */ protected String[] formatRow(AbstractMatrix1D vector) { Former formatter = null; formatter = factory.create(format); int s = (int) vector.size(); String[] strings = new String[s]; for (int i = 0; i < s; i++) { strings[i] = form(vector, i, formatter); } return strings; }
/** * Sanity check for operations requiring an index to be within bounds. * * @throws IndexOutOfBoundsException * if <tt>index < 0 || index >= size()</tt>. */ protected void checkIndex(int index) { if (index < 0 || index >= size) throw new IndexOutOfBoundsException("Attempted to access " + toStringShort() + " at index=" + index); }
/** * Returns a string representations of all cells; no alignment considered. */ protected String[] formatRow(AbstractMatrix1D vector) { Former formatter = null; formatter = factory.create(format); int s = (int) vector.size(); String[] strings = new String[s]; for (int i = 0; i < s; i++) { strings[i] = form(vector, i, formatter); } return strings; }
/** * Returns the stride of the given dimension (axis, rank). * * @dimension the index of the dimension. * @return the stride in the given dimension. * @throws IllegalArgumentException * if <tt>dimension != 0</tt>. */ protected int stride(int dimension) { if (dimension != 0) throw new IllegalArgumentException("invalid dimension: " + dimension + "used to access" + toStringShort()); return this.stride; }