public ColtSparseDoubleMatrix2D(int rows, int columns) { super(rows, columns); this.matrix = new SparseDoubleMatrix2D(rows, columns); }
/** * Construct and returns a new 2-d matrix <i>of the corresponding dynamic type</i>, entirelly independent of the receiver. * For example, if the receiver is an instance of type <tt>DenseDoubleMatrix1D</tt> the new matrix must be of type <tt>DenseDoubleMatrix2D</tt>, * if the receiver is an instance of type <tt>SparseDoubleMatrix1D</tt> the new matrix must be of type <tt>SparseDoubleMatrix2D</tt>, etc. * * @param rows the number of rows the matrix shall have. * @param columns the number of columns the matrix shall have. * @return a new matrix of the corresponding dynamic type. */ public DoubleMatrix2D like2D(int rows, int columns) { return new SparseDoubleMatrix2D(rows,columns); } /**
/** * Construct and returns a new empty matrix <i>of the same dynamic type</i> as the receiver, having the specified number of rows and columns. * For example, if the receiver is an instance of type <tt>DenseDoubleMatrix2D</tt> the new matrix must also be of type <tt>DenseDoubleMatrix2D</tt>, * if the receiver is an instance of type <tt>SparseDoubleMatrix2D</tt> the new matrix must also be of type <tt>SparseDoubleMatrix2D</tt>, etc. * In general, the new matrix should have internal parametrization as similar as possible. * * @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 DoubleMatrix2D like(int rows, int columns) { return new SparseDoubleMatrix2D(rows, columns); } /**
/** * Construct and returns a new 2-d matrix <i>of the corresponding dynamic type</i>, entirelly independent of the receiver. * For example, if the receiver is an instance of type <tt>DenseDoubleMatrix1D</tt> the new matrix must be of type <tt>DenseDoubleMatrix2D</tt>, * if the receiver is an instance of type <tt>SparseDoubleMatrix1D</tt> the new matrix must be of type <tt>SparseDoubleMatrix2D</tt>, etc. * * @param rows the number of rows the matrix shall have. * @param columns the number of columns the matrix shall have. * @return a new matrix of the corresponding dynamic type. */ public DoubleMatrix2D like2D(int rows, int columns) { return new SparseDoubleMatrix2D(rows,columns); } /**
/** * Construct and returns a new 2-d matrix <i>of the corresponding dynamic type</i>, entirelly independent of the receiver. * For example, if the receiver is an instance of type <tt>DenseDoubleMatrix1D</tt> the new matrix must be of type <tt>DenseDoubleMatrix2D</tt>, * if the receiver is an instance of type <tt>SparseDoubleMatrix1D</tt> the new matrix must be of type <tt>SparseDoubleMatrix2D</tt>, etc. * * @param rows the number of rows the matrix shall have. * @param columns the number of columns the matrix shall have. * @return a new matrix of the corresponding dynamic type. */ public DoubleMatrix2D like2D(int rows, int columns) { return new SparseDoubleMatrix2D(rows,columns); } /**
/** * Construct and returns a new 2-d matrix <i>of the corresponding dynamic type</i>, entirelly independent of the receiver. * For example, if the receiver is an instance of type <tt>DenseDoubleMatrix1D</tt> the new matrix must be of type <tt>DenseDoubleMatrix2D</tt>, * if the receiver is an instance of type <tt>SparseDoubleMatrix1D</tt> the new matrix must be of type <tt>SparseDoubleMatrix2D</tt>, etc. * * @param rows the number of rows the matrix shall have. * @param columns the number of columns the matrix shall have. * @return a new matrix of the corresponding dynamic type. */ public DoubleMatrix2D like2D(int rows, int columns) { return new SparseDoubleMatrix2D(rows,columns); } /**
public ColtSparseDoubleMatrix2D(int rows, int columns) { super(rows, columns); this.matrix = new SparseDoubleMatrix2D(rows, columns); }
/** * Construct and returns a new empty matrix <i>of the same dynamic type</i> as the receiver, having the specified number of rows and columns. * For example, if the receiver is an instance of type <tt>DenseDoubleMatrix2D</tt> the new matrix must also be of type <tt>DenseDoubleMatrix2D</tt>, * if the receiver is an instance of type <tt>SparseDoubleMatrix2D</tt> the new matrix must also be of type <tt>SparseDoubleMatrix2D</tt>, etc. * In general, the new matrix should have internal parametrization as similar as possible. * * @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 DoubleMatrix2D like(int rows, int columns) { return new SparseDoubleMatrix2D(rows, columns); } /**
/** * Construct and returns a new empty matrix <i>of the same dynamic type</i> as the receiver, having the specified number of rows and columns. * For example, if the receiver is an instance of type <tt>DenseDoubleMatrix2D</tt> the new matrix must also be of type <tt>DenseDoubleMatrix2D</tt>, * if the receiver is an instance of type <tt>SparseDoubleMatrix2D</tt> the new matrix must also be of type <tt>SparseDoubleMatrix2D</tt>, etc. * In general, the new matrix should have internal parametrization as similar as possible. * * @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 DoubleMatrix2D like(int rows, int columns) { return new SparseDoubleMatrix2D(rows, columns); } /**
/** * Construct and returns a new empty matrix <i>of the same dynamic type</i> as the receiver, having the specified number of rows and columns. * For example, if the receiver is an instance of type <tt>DenseDoubleMatrix2D</tt> the new matrix must also be of type <tt>DenseDoubleMatrix2D</tt>, * if the receiver is an instance of type <tt>SparseDoubleMatrix2D</tt> the new matrix must also be of type <tt>SparseDoubleMatrix2D</tt>, etc. * In general, the new matrix should have internal parametrization as similar as possible. * * @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 DoubleMatrix2D like(int rows, int columns) { return new SparseDoubleMatrix2D(rows, columns); } /**
/** * Construct and returns a new 2-d matrix <i>of the corresponding dynamic type</i>, sharing the same cells. * For example, if the receiver is an instance of type <tt>DenseDoubleMatrix3D</tt> the new matrix must also be of type <tt>DenseDoubleMatrix2D</tt>, * if the receiver is an instance of type <tt>SparseDoubleMatrix3D</tt> the new matrix must also be of type <tt>SparseDoubleMatrix2D</tt>, etc. * * @param rows the number of rows the matrix shall have. * @param columns the number of columns the matrix shall have. * @param rowZero the position of the first element. * @param columnZero the position of the first element. * @param rowStride the number of elements between two rows, i.e. <tt>index(i+1,j)-index(i,j)</tt>. * @param columnStride the number of elements between two columns, i.e. <tt>index(i,j+1)-index(i,j)</tt>. * @return a new matrix of the corresponding dynamic type. */ protected DoubleMatrix2D like2D(int rows, int columns, int rowZero, int columnZero, int rowStride, int columnStride) { return new SparseDoubleMatrix2D(rows,columns,this.elements,rowZero,columnZero,rowStride,columnStride); } /**
/** * Construct and returns a new 2-d matrix <i>of the corresponding dynamic type</i>, sharing the same cells. * For example, if the receiver is an instance of type <tt>DenseDoubleMatrix3D</tt> the new matrix must also be of type <tt>DenseDoubleMatrix2D</tt>, * if the receiver is an instance of type <tt>SparseDoubleMatrix3D</tt> the new matrix must also be of type <tt>SparseDoubleMatrix2D</tt>, etc. * * @param rows the number of rows the matrix shall have. * @param columns the number of columns the matrix shall have. * @param rowZero the position of the first element. * @param columnZero the position of the first element. * @param rowStride the number of elements between two rows, i.e. <tt>index(i+1,j)-index(i,j)</tt>. * @param columnStride the number of elements between two columns, i.e. <tt>index(i,j+1)-index(i,j)</tt>. * @return a new matrix of the corresponding dynamic type. */ protected DoubleMatrix2D like2D(int rows, int columns, int rowZero, int columnZero, int rowStride, int columnStride) { return new SparseDoubleMatrix2D(rows,columns,this.elements,rowZero,columnZero,rowStride,columnStride); } /**
/** * Constructs a matrix with the given cell values. * <tt>values</tt> is required to have the form <tt>values[row][column]</tt> * and have exactly the same number of columns 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 <= row < values.length: values[row].length != values[row-1].length</tt>. */ public DoubleMatrix2D make(double[][] values) { if (this==sparse) return new SparseDoubleMatrix2D(values); else return new DenseDoubleMatrix2D(values); } /**
/** * Constructs a matrix with the given cell values. * <tt>values</tt> is required to have the form <tt>values[row][column]</tt> * and have exactly the same number of columns 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 <= row < values.length: values[row].length != values[row-1].length</tt>. */ public DoubleMatrix2D make(double[][] values) { if (this==sparse) return new SparseDoubleMatrix2D(values); else return new DenseDoubleMatrix2D(values); } /**
/** * Constructs a matrix with the given shape, each cell initialized with zero. */ public DoubleMatrix2D make(int rows, int columns) { if (this==sparse) return new SparseDoubleMatrix2D(rows,columns); if (this==rowCompressed) return new RCDoubleMatrix2D(rows,columns); //if (this==rowCompressedModified) return new RCMDoubleMatrix2D(rows,columns); else return new DenseDoubleMatrix2D(rows,columns); } /**
/** * Constructs a matrix with the given shape, each cell initialized with zero. */ public DoubleMatrix2D make(int rows, int columns) { if (this==sparse) return new SparseDoubleMatrix2D(rows,columns); if (this==rowCompressed) return new RCDoubleMatrix2D(rows,columns); //if (this==rowCompressedModified) return new RCMDoubleMatrix2D(rows,columns); else return new DenseDoubleMatrix2D(rows,columns); } /**
public Matrix mtimes(Matrix m) { if (m instanceof ColtSparseDoubleMatrix2D) { SparseDoubleMatrix2D ret = new SparseDoubleMatrix2D((int) getRowCount(), (int) m.getColumnCount()); matrix.zMult(((ColtSparseDoubleMatrix2D) m).matrix, ret); return new ColtSparseDoubleMatrix2D(ret); } else { return super.mtimes(m); } }
public Matrix mtimes(Matrix m) { if (m instanceof ColtSparseDoubleMatrix2D) { SparseDoubleMatrix2D ret = new SparseDoubleMatrix2D((int) getRowCount(), (int) m.getColumnCount()); matrix.zMult(((ColtSparseDoubleMatrix2D) m).matrix, ret); return new ColtSparseDoubleMatrix2D(ret); } else { return super.mtimes(m); } }
public ColtSparseDoubleMatrix2D(Matrix source) { super(source.getRowCount(), source.getColumnCount()); this.matrix = new SparseDoubleMatrix2D((int) source.getRowCount(), (int) source.getColumnCount()); for (long[] c : source.availableCoordinates()) { setDouble(source.getAsDouble(c), c); } if (source.getMetaData() != null) { setMetaData(source.getMetaData().clone()); } }
public ColtSparseDoubleMatrix2D(Matrix source) { super(source.getRowCount(), source.getColumnCount()); this.matrix = new SparseDoubleMatrix2D((int) source.getRowCount(), (int) source.getColumnCount()); for (long[] c : source.availableCoordinates()) { setDouble(source.getAsDouble(c), c); } if (source.getMetaData() != null) { setMetaData(source.getMetaData().clone()); } }