/** * Construct and returns a new empty matrix <i>of the same dynamic type</i> as the receiver, having the specified number of slices, rows and columns. * For example, if the receiver is an instance of type <tt>DenseObjectMatrix3D</tt> the new matrix must also be of type <tt>DenseObjectMatrix3D</tt>, * if the receiver is an instance of type <tt>SparseObjectMatrix3D</tt> the new matrix must also be of type <tt>SparseObjectMatrix3D</tt>, etc. * In general, the new matrix should have internal parametrization as similar as possible. * * @param slices the number of slices the matrix shall have. * @param rows the number of rows the matrix shall have. * @param columns the number of columns the matrix shall have. * @return a new empty matrix of the same dynamic type. */ public ObjectMatrix3D like(int slices, int rows, int columns) { return new SparseObjectMatrix3D(slices,rows,columns); } /**
/** * Constructs a matrix with a copy of the given values. * <tt>values</tt> is required to have the form <tt>values[slice][row][column]</tt> * and have exactly the same number of rows in in every slice and exactly the same number of columns in in every row. * <p> * 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. * @throws IllegalArgumentException if <tt>for any 1 <= slice < values.length: values[slice].length != values[slice-1].length</tt>. * @throws IllegalArgumentException if <tt>for any 1 <= row < values[0].length: values[slice][row].length != values[slice][row-1].length</tt>. */ public SparseObjectMatrix3D(Object[][][] values) { this(values.length, (values.length==0 ? 0: values[0].length), (values.length==0 ? 0: values[0].length==0 ? 0 : values[0][0].length)); assign(values); } /**
/** * Constructs a view with the given parameters. * @param slices the number of slices the matrix shall have. * @param rows the number of rows the matrix shall have. * @param columns the number of columns the matrix shall have. * @param elements the cells. * @param sliceZero the position of the first element. * @param rowZero the position of the first element. * @param columnZero the position of the first element. * @param sliceStride the number of elements between two slices, i.e. <tt>index(k+1,i,j)-index(k,i,j)</tt>. * @param rowStride the number of elements between two rows, i.e. <tt>index(k,i+1,j)-index(k,i,j)</tt>. * @param columnnStride the number of elements between two columns, i.e. <tt>index(k,i,j+1)-index(k,i,j)</tt>. * @throws IllegalArgumentException if <tt>(Object)slices*columns*rows > Integer.MAX_VALUE</tt>. * @throws IllegalArgumentException if <tt>slices<0 || rows<0 || columns<0</tt>. */ protected SparseObjectMatrix3D(int slices, int rows, int columns, AbstractIntObjectMap elements, int sliceZero, int rowZero, int columnZero, int sliceStride, int rowStride, int columnStride) { setUp(slices,rows,columns,sliceZero,rowZero,columnZero,sliceStride,rowStride,columnStride); this.elements = elements; this.isNoView = false; } /**
/** * Construct and returns a new empty matrix <i>of the same dynamic type</i> as the receiver, having the specified number of slices, rows and columns. * For example, if the receiver is an instance of type <tt>DenseObjectMatrix3D</tt> the new matrix must also be of type <tt>DenseObjectMatrix3D</tt>, * if the receiver is an instance of type <tt>SparseObjectMatrix3D</tt> the new matrix must also be of type <tt>SparseObjectMatrix3D</tt>, etc. * In general, the new matrix should have internal parametrization as similar as possible. * * @param slices the number of slices the matrix shall have. * @param rows the number of rows the matrix shall have. * @param columns the number of columns the matrix shall have. * @return a new empty matrix of the same dynamic type. */ public ObjectMatrix3D like(int slices, int rows, int columns) { return new SparseObjectMatrix3D(slices,rows,columns); } /**
/** * Constructs a view with the given parameters. * @param slices the number of slices the matrix shall have. * @param rows the number of rows the matrix shall have. * @param columns the number of columns the matrix shall have. * @param elements the cells. * @param sliceZero the position of the first element. * @param rowZero the position of the first element. * @param columnZero the position of the first element. * @param sliceStride the number of elements between two slices, i.e. <tt>index(k+1,i,j)-index(k,i,j)</tt>. * @param rowStride the number of elements between two rows, i.e. <tt>index(k,i+1,j)-index(k,i,j)</tt>. * @param columnnStride the number of elements between two columns, i.e. <tt>index(k,i,j+1)-index(k,i,j)</tt>. * @throws IllegalArgumentException if <tt>(Object)slices*columns*rows > Integer.MAX_VALUE</tt>. * @throws IllegalArgumentException if <tt>slices<0 || rows<0 || columns<0</tt>. */ protected SparseObjectMatrix3D(int slices, int rows, int columns, AbstractIntObjectMap elements, int sliceZero, int rowZero, int columnZero, int sliceStride, int rowStride, int columnStride) { setUp(slices,rows,columns,sliceZero,rowZero,columnZero,sliceStride,rowStride,columnStride); this.elements = elements; this.isNoView = false; } /**
/** * Constructs a matrix with a copy of the given values. * <tt>values</tt> is required to have the form <tt>values[slice][row][column]</tt> * and have exactly the same number of rows in in every slice and exactly the same number of columns in in every row. * <p> * 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. * @throws IllegalArgumentException if <tt>for any 1 <= slice < values.length: values[slice].length != values[slice-1].length</tt>. * @throws IllegalArgumentException if <tt>for any 1 <= row < values[0].length: values[slice][row].length != values[slice][row-1].length</tt>. */ public SparseObjectMatrix3D(Object[][][] values) { this(values.length, (values.length==0 ? 0: values[0].length), (values.length==0 ? 0: values[0].length==0 ? 0 : values[0][0].length)); assign(values); } /**
/** * Construct and returns a new empty matrix <i>of the same dynamic type</i> as the receiver, having the specified number of slices, rows and columns. * For example, if the receiver is an instance of type <tt>DenseObjectMatrix3D</tt> the new matrix must also be of type <tt>DenseObjectMatrix3D</tt>, * if the receiver is an instance of type <tt>SparseObjectMatrix3D</tt> the new matrix must also be of type <tt>SparseObjectMatrix3D</tt>, etc. * In general, the new matrix should have internal parametrization as similar as possible. * * @param slices the number of slices the matrix shall have. * @param rows the number of rows the matrix shall have. * @param columns the number of columns the matrix shall have. * @return a new empty matrix of the same dynamic type. */ public ObjectMatrix3D like(int slices, int rows, int columns) { return new SparseObjectMatrix3D(slices,rows,columns); } /**
/** * Constructs a matrix with a given number of slices, rows and columns using memory as specified. * All entries are initially <tt>null</tt>. * For details related to memory usage see {@link cern.colt.map.OpenIntObjectHashMap}. * * @param slices the number of slices the matrix shall have. * @param rows the number of rows the matrix shall have. * @param columns the number of columns 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>(double)slices*columns*rows > Integer.MAX_VALUE</tt>. * @throws IllegalArgumentException if <tt>slices<0 || rows<0 || columns<0</tt>. */ public SparseObjectMatrix3D(int slices, int rows, int columns, int initialCapacity, double minLoadFactor, double maxLoadFactor) { setUp(slices,rows,columns); this.elements = new OpenIntObjectHashMap(initialCapacity, minLoadFactor, maxLoadFactor); } /**
/** * Construct and returns a new empty matrix <i>of the same dynamic type</i> as the receiver, having the specified number of slices, rows and columns. * For example, if the receiver is an instance of type <tt>DenseObjectMatrix3D</tt> the new matrix must also be of type <tt>DenseObjectMatrix3D</tt>, * if the receiver is an instance of type <tt>SparseObjectMatrix3D</tt> the new matrix must also be of type <tt>SparseObjectMatrix3D</tt>, etc. * In general, the new matrix should have internal parametrization as similar as possible. * * @param slices the number of slices the matrix shall have. * @param rows the number of rows the matrix shall have. * @param columns the number of columns the matrix shall have. * @return a new empty matrix of the same dynamic type. */ public ObjectMatrix3D like(int slices, int rows, int columns) { return new SparseObjectMatrix3D(slices,rows,columns); } /**
/** * Constructs a matrix with a given number of slices, rows and columns using memory as specified. * All entries are initially <tt>null</tt>. * For details related to memory usage see {@link cern.colt.map.OpenIntObjectHashMap}. * * @param slices the number of slices the matrix shall have. * @param rows the number of rows the matrix shall have. * @param columns the number of columns 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>(double)slices*columns*rows > Integer.MAX_VALUE</tt>. * @throws IllegalArgumentException if <tt>slices<0 || rows<0 || columns<0</tt>. */ public SparseObjectMatrix3D(int slices, int rows, int columns, int initialCapacity, double minLoadFactor, double maxLoadFactor) { setUp(slices,rows,columns); this.elements = new OpenIntObjectHashMap(initialCapacity, minLoadFactor, maxLoadFactor); } /**
/** * Constructs a matrix with the given shape, each cell initialized with zero. */ public ObjectMatrix3D make(int slices, int rows, int columns) { if (this==sparse) return new SparseObjectMatrix3D(slices,rows,columns); return new DenseObjectMatrix3D(slices,rows,columns); } /**
/** * Constructs a matrix with the given shape, each cell initialized with zero. */ public ObjectMatrix3D make(int slices, int rows, int columns) { if (this==sparse) return new SparseObjectMatrix3D(slices,rows,columns); return new DenseObjectMatrix3D(slices,rows,columns); } /**
/** * Constructs a matrix with the given cell values. * <tt>values</tt> is required to have the form <tt>values[slice][row][column]</tt> * and have exactly the same number of slices, rows and columns as the receiver. * <p> * 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 cells. * @return <tt>this</tt> (for convenience only). * @throws IllegalArgumentException if <tt>values.length != slices() || for any 0 <= slice < slices(): values[slice].length != rows()</tt>. * @throws IllegalArgumentException if <tt>for any 0 <= column < columns(): values[slice][row].length != columns()</tt>. */ public ObjectMatrix3D make(Object[][][] values) { if (this==sparse) return new SparseObjectMatrix3D(values); return new DenseObjectMatrix3D(values); } /**
/** * Constructs a matrix with the given cell values. * <tt>values</tt> is required to have the form <tt>values[slice][row][column]</tt> * and have exactly the same number of slices, rows and columns as the receiver. * <p> * 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 cells. * @return <tt>this</tt> (for convenience only). * @throws IllegalArgumentException if <tt>values.length != slices() || for any 0 <= slice < slices(): values[slice].length != rows()</tt>. * @throws IllegalArgumentException if <tt>for any 0 <= column < columns(): values[slice][row].length != columns()</tt>. */ public ObjectMatrix3D make(Object[][][] values) { if (this==sparse) return new SparseObjectMatrix3D(values); return new DenseObjectMatrix3D(values); } /**