checkSliceIndexes(sliceIndexes); checkRowIndexes(rowIndexes); checkColumnIndexes(columnIndexes); sliceOffsets[i] = _sliceOffset(_sliceRank(sliceIndexes[i])); rowOffsets[i] = _rowOffset(_rowRank(rowIndexes[i])); columnOffsets[i] = _columnOffset(_columnRank(columnIndexes[i])); return viewSelectionLike(sliceOffsets,rowOffsets,columnOffsets);
/** * Constructs and returns a deep copy of the receiver. * <p> * <b>Note that the returned matrix is an independent deep copy.</b> * The returned matrix is not backed by this matrix, so changes in the returned matrix are not reflected in this matrix, and vice-versa. * * @return a deep copy of the receiver. */ public DoubleMatrix3D copy() { return like().assign(this); } /**
/** Constructs and returns a new 2-dimensional <i>slice view</i> representing the slices and columns of the given row. The returned view is backed by this matrix, so changes in the returned view are reflected in this matrix, and vice-versa. <p> To obtain a slice view on subranges, construct a sub-ranging view (<tt>view().part(...)</tt>), then apply this method to the sub-range view. To obtain 1-dimensional views, apply this method, then apply another slice view (methods <tt>viewColumn</tt>, <tt>viewRow</tt>) on the intermediate 2-dimensional view. To obtain 1-dimensional views on subranges, apply both steps. @param row the index of the row to fix. @return a new 2-dimensional slice view. @throws IndexOutOfBoundsException if <tt>row < 0 || row >= row()</tt>. @see #viewSlice(int) @see #viewColumn(int) */ public DoubleMatrix2D viewRow(int row) { checkRow(row); int sliceRows = this.slices; int sliceColumns = this.columns; //int sliceOffset = index(0,row,0); int sliceRowZero = sliceZero ; int sliceColumnZero = columnZero + _rowOffset(_rowRank(row)); int sliceRowStride = this.sliceStride; int sliceColumnStride = this.columnStride; return like2D(sliceRows,sliceColumns,sliceRowZero,sliceColumnZero,sliceRowStride,sliceColumnStride); } /**
/** Constructs and returns a new 2-dimensional <i>slice view</i> representing the slices and rows of the given column. The returned view is backed by this matrix, so changes in the returned view are reflected in this matrix, and vice-versa. <p> To obtain a slice view on subranges, construct a sub-ranging view (<tt>view().part(...)</tt>), then apply this method to the sub-range view. To obtain 1-dimensional views, apply this method, then apply another slice view (methods <tt>viewColumn</tt>, <tt>viewRow</tt>) on the intermediate 2-dimensional view. To obtain 1-dimensional views on subranges, apply both steps. @param column the index of the column to fix. @return a new 2-dimensional slice view. @throws IndexOutOfBoundsException if <tt>column < 0 || column >= columns()</tt>. @see #viewSlice(int) @see #viewRow(int) */ public DoubleMatrix2D viewColumn(int column) { checkColumn(column); int sliceRows = this.slices; int sliceColumns = this.rows; //int sliceOffset = index(0,0,column); int sliceRowZero = sliceZero; int sliceColumnZero = rowZero + _columnOffset(_columnRank(column)); int sliceRowStride = this.sliceStride; int sliceColumnStride = this.rowStride; return like2D(sliceRows,sliceColumns,sliceRowZero,sliceColumnZero,sliceRowStride,sliceColumnStride); } /**
/** Constructs and returns a new 2-dimensional <i>slice view</i> representing the rows and columns of the given slice. The returned view is backed by this matrix, so changes in the returned view are reflected in this matrix, and vice-versa. <p> To obtain a slice view on subranges, construct a sub-ranging view (<tt>view().part(...)</tt>), then apply this method to the sub-range view. To obtain 1-dimensional views, apply this method, then apply another slice view (methods <tt>viewColumn</tt>, <tt>viewRow</tt>) on the intermediate 2-dimensional view. To obtain 1-dimensional views on subranges, apply both steps. @param slice the index of the slice to fix. @return a new 2-dimensional slice view. @throws IndexOutOfBoundsException if <tt>slice < 0 || slice >= slices()</tt>. @see #viewRow(int) @see #viewColumn(int) */ public DoubleMatrix2D viewSlice(int slice) { checkSlice(slice); int sliceRows = this.rows; int sliceColumns = this.columns; //int sliceOffset = index(slice,0,0); int sliceRowZero = rowZero; int sliceColumnZero = columnZero + _sliceOffset(_sliceRank(slice)); int sliceRowStride = this.rowStride; int sliceColumnStride = this.columnStride; return like2D(sliceRows,sliceColumns,sliceRowZero,sliceColumnZero,sliceRowStride,sliceColumnStride); } /**
/** * Constructs a matrix with the given shape, each cell initialized with the given value. */ public DoubleMatrix3D make(int slices, int rows, int columns, double initialValue) { return make(slices,rows,columns).assign(initialValue); } /**
/** * Returns the number of cells having non-zero values. */ public int cardinality() { if (this.isNoView) return this.elements.size(); else return super.cardinality(); } /**
/** Constructs and returns a new 2-dimensional <i>slice view</i> representing the slices and columns of the given row. The returned view is backed by this matrix, so changes in the returned view are reflected in this matrix, and vice-versa. <p> To obtain a slice view on subranges, construct a sub-ranging view (<tt>view().part(...)</tt>), then apply this method to the sub-range view. To obtain 1-dimensional views, apply this method, then apply another slice view (methods <tt>viewColumn</tt>, <tt>viewRow</tt>) on the intermediate 2-dimensional view. To obtain 1-dimensional views on subranges, apply both steps. @param row the index of the row to fix. @return a new 2-dimensional slice view. @throws IndexOutOfBoundsException if <tt>row < 0 || row >= row()</tt>. @see #viewSlice(int) @see #viewColumn(int) */ public DoubleMatrix2D viewRow(int row) { checkRow(row); int sliceRows = this.slices; int sliceColumns = this.columns; //int sliceOffset = index(0,row,0); int sliceRowZero = sliceZero ; int sliceColumnZero = columnZero + _rowOffset(_rowRank(row)); int sliceRowStride = this.sliceStride; int sliceColumnStride = this.columnStride; return like2D(sliceRows,sliceColumns,sliceRowZero,sliceColumnZero,sliceRowStride,sliceColumnStride); } /**
/** Constructs and returns a new 2-dimensional <i>slice view</i> representing the slices and rows of the given column. The returned view is backed by this matrix, so changes in the returned view are reflected in this matrix, and vice-versa. <p> To obtain a slice view on subranges, construct a sub-ranging view (<tt>view().part(...)</tt>), then apply this method to the sub-range view. To obtain 1-dimensional views, apply this method, then apply another slice view (methods <tt>viewColumn</tt>, <tt>viewRow</tt>) on the intermediate 2-dimensional view. To obtain 1-dimensional views on subranges, apply both steps. @param column the index of the column to fix. @return a new 2-dimensional slice view. @throws IndexOutOfBoundsException if <tt>column < 0 || column >= columns()</tt>. @see #viewSlice(int) @see #viewRow(int) */ public DoubleMatrix2D viewColumn(int column) { checkColumn(column); int sliceRows = this.slices; int sliceColumns = this.rows; //int sliceOffset = index(0,0,column); int sliceRowZero = sliceZero; int sliceColumnZero = rowZero + _columnOffset(_columnRank(column)); int sliceRowStride = this.sliceStride; int sliceColumnStride = this.rowStride; return like2D(sliceRows,sliceColumns,sliceRowZero,sliceColumnZero,sliceRowStride,sliceColumnStride); } /**
/** Constructs and returns a new 2-dimensional <i>slice view</i> representing the rows and columns of the given slice. The returned view is backed by this matrix, so changes in the returned view are reflected in this matrix, and vice-versa. <p> To obtain a slice view on subranges, construct a sub-ranging view (<tt>view().part(...)</tt>), then apply this method to the sub-range view. To obtain 1-dimensional views, apply this method, then apply another slice view (methods <tt>viewColumn</tt>, <tt>viewRow</tt>) on the intermediate 2-dimensional view. To obtain 1-dimensional views on subranges, apply both steps. @param slice the index of the slice to fix. @return a new 2-dimensional slice view. @throws IndexOutOfBoundsException if <tt>slice < 0 || slice >= slices()</tt>. @see #viewRow(int) @see #viewColumn(int) */ public DoubleMatrix2D viewSlice(int slice) { checkSlice(slice); int sliceRows = this.rows; int sliceColumns = this.columns; //int sliceOffset = index(slice,0,0); int sliceRowZero = rowZero; int sliceColumnZero = columnZero + _sliceOffset(_sliceRank(slice)); int sliceRowStride = this.rowStride; int sliceColumnStride = this.columnStride; return like2D(sliceRows,sliceColumns,sliceRowZero,sliceColumnZero,sliceRowStride,sliceColumnStride); } /**
/** * Constructs a matrix with the given shape, each cell initialized with the given value. */ public DoubleMatrix3D make(int slices, int rows, int columns, double initialValue) { return make(slices,rows,columns).assign(initialValue); } /**
/** * Returns the number of cells having non-zero values. */ public int cardinality() { if (this.isNoView) return this.elements.size(); else return super.cardinality(); } /**
checkSliceIndexes(sliceIndexes); checkRowIndexes(rowIndexes); checkColumnIndexes(columnIndexes); sliceOffsets[i] = _sliceOffset(_sliceRank(sliceIndexes[i])); rowOffsets[i] = _rowOffset(_rowRank(rowIndexes[i])); columnOffsets[i] = _columnOffset(_columnRank(columnIndexes[i])); return viewSelectionLike(sliceOffsets,rowOffsets,columnOffsets);
/** * Sets all cells to the state specified by <tt>value</tt>. * @param value the value to be filled into the cells. * @return <tt>this</tt> (for convenience only). */ public DoubleMatrix3D assign(double value) { // overriden for performance only if (this.isNoView && value==0) this.elements.clear(); else super.assign(value); return this; } /**
/** * Constructs and returns a deep copy of the receiver. * <p> * <b>Note that the returned matrix is an independent deep copy.</b> * The returned matrix is not backed by this matrix, so changes in the returned matrix are not reflected in this matrix, and vice-versa. * * @return a deep copy of the receiver. */ public DoubleMatrix3D copy() { return like().assign(this); } /**
/** * Sets all cells to the state specified by <tt>value</tt>. * @param value the value to be filled into the cells. * @return <tt>this</tt> (for convenience only). */ public DoubleMatrix3D assign(double value) { // overriden for performance only if (this.isNoView && value==0) this.elements.clear(); else super.assign(value); return this; } /**