/** * Construct and returns a new 1-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>DenseDoubleMatrix2D</tt> the new matrix must be of type <tt>DenseDoubleMatrix1D</tt>, * if the receiver is an instance of type <tt>SparseDoubleMatrix2D</tt> the new matrix must be of type <tt>SparseDoubleMatrix1D</tt>, etc. * * @param size the number of cells the matrix shall have. * @return a new matrix of the corresponding dynamic type. */ public DoubleMatrix1D like1D(int size) { return new SparseDoubleMatrix1D(size); } /**
/** * Constructs a matrix with a copy of the given values. * 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. */ public SparseDoubleMatrix1D(double[] values) { this(values.length); assign(values); } /**
/** * Constructs a matrix view with a given number of parameters. * * @param size the number of cells the matrix shall have. * @param elements the cells. * @param offset the index of the first element. * @param stride the number of indexes between any two elements, i.e. <tt>index(i+1)-index(i)</tt>. * @throws IllegalArgumentException if <tt>size<0</tt>. */ protected SparseDoubleMatrix1D(int size, AbstractIntDoubleMap elements, int offset, int stride) { setUp(size,offset,stride); this.elements = elements; this.isNoView = false; } /**
protected double normQuick(SparseDoubleMatrix1D v) { IntArrayList indexList = new IntArrayList(); DoubleArrayList valueList = new DoubleArrayList(); v.getNonZeros(indexList, valueList); double norm = 0.0; for (int i = 0; i < valueList.size(); ++i) { norm += valueList.get(i) * valueList.get(i); } return norm; }
/** * Construct and returns a new 1-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>DenseDoubleMatrix2D</tt> the new matrix must be of type <tt>DenseDoubleMatrix1D</tt>, * if the receiver is an instance of type <tt>SparseDoubleMatrix2D</tt> the new matrix must be of type <tt>SparseDoubleMatrix1D</tt>, etc. * * @param size the number of cells the matrix shall have. * @return a new matrix of the corresponding dynamic type. */ public DoubleMatrix1D like1D(int size) { return new SparseDoubleMatrix1D(size); } /**
/** * Constructs a matrix view with a given number of parameters. * * @param size the number of cells the matrix shall have. * @param elements the cells. * @param offset the index of the first element. * @param stride the number of indexes between any two elements, i.e. <tt>index(i+1)-index(i)</tt>. * @throws IllegalArgumentException if <tt>size<0</tt>. */ protected SparseDoubleMatrix1D(int size, AbstractIntDoubleMap elements, int offset, int stride) { setUp(size,offset,stride); this.elements = elements; this.isNoView = false; } /**
/** * Constructs a matrix with a copy of the given values. * 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. */ public SparseDoubleMatrix1D(double[] values) { this(values.length); assign(values); } /**
/** * Construct and returns a new 1-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>DenseDoubleMatrix2D</tt> the new matrix must be of type <tt>DenseDoubleMatrix1D</tt>, * if the receiver is an instance of type <tt>SparseDoubleMatrix2D</tt> the new matrix must be of type <tt>SparseDoubleMatrix1D</tt>, etc. * * @param size the number of cells the matrix shall have. * @return a new matrix of the corresponding dynamic type. */ public DoubleMatrix1D like1D(int size) { return new SparseDoubleMatrix1D(size); } /**
/** * Constructs a matrix with a given number of parameters. * All entries are initially <tt>0</tt>. * For details related to memory usage see {@link cern.colt.map.OpenIntDoubleHashMap}. * * @param size the number of cells 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>size<0</tt>. */ public SparseDoubleMatrix1D(int size, int initialCapacity, double minLoadFactor, double maxLoadFactor) { setUp(size); this.elements = new OpenIntDoubleHashMap(initialCapacity, minLoadFactor, maxLoadFactor); } /**
/** * Construct and returns a new 1-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>DenseDoubleMatrix2D</tt> the new matrix must be of type <tt>DenseDoubleMatrix1D</tt>, * if the receiver is an instance of type <tt>SparseDoubleMatrix2D</tt> the new matrix must be of type <tt>SparseDoubleMatrix1D</tt>, etc. * * @param size the number of cells the matrix shall have. * @return a new matrix of the corresponding dynamic type. */ public DoubleMatrix1D like1D(int size) { return new SparseDoubleMatrix1D(size); } /**
/** * Constructs a matrix with a given number of parameters. * All entries are initially <tt>0</tt>. * For details related to memory usage see {@link cern.colt.map.OpenIntDoubleHashMap}. * * @param size the number of cells 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>size<0</tt>. */ public SparseDoubleMatrix1D(int size, int initialCapacity, double minLoadFactor, double maxLoadFactor) { setUp(size); this.elements = new OpenIntDoubleHashMap(initialCapacity, minLoadFactor, maxLoadFactor); } /**
/** * Construct and returns a new 1-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>DenseDoubleMatrix2D</tt> the new matrix must be of type <tt>DenseDoubleMatrix1D</tt>, * if the receiver is an instance of type <tt>SparseDoubleMatrix2D</tt> the new matrix must be of type <tt>SparseDoubleMatrix1D</tt>, etc. * * @param size the number of cells the matrix shall have. * @return a new matrix of the corresponding dynamic type. */ public DoubleMatrix1D like1D(int size) { return new SparseDoubleMatrix1D(size); } /**
/** * Construct and returns a new empty matrix <i>of the same dynamic type</i> as the receiver, having the specified size. * For example, if the receiver is an instance of type <tt>DenseDoubleMatrix1D</tt> the new matrix must also be of type <tt>DenseDoubleMatrix1D</tt>, * if the receiver is an instance of type <tt>SparseDoubleMatrix1D</tt> the new matrix must also be of type <tt>SparseDoubleMatrix1D</tt>, etc. * In general, the new matrix should have internal parametrization as similar as possible. * * @param size the number of cell the matrix shall have. * @return a new empty matrix of the same dynamic type. */ public DoubleMatrix1D like(int size) { return new SparseDoubleMatrix1D(size); } /**
/** * Construct and returns a new empty matrix <i>of the same dynamic type</i> as the receiver, having the specified size. * For example, if the receiver is an instance of type <tt>DenseDoubleMatrix1D</tt> the new matrix must also be of type <tt>DenseDoubleMatrix1D</tt>, * if the receiver is an instance of type <tt>SparseDoubleMatrix1D</tt> the new matrix must also be of type <tt>SparseDoubleMatrix1D</tt>, etc. * In general, the new matrix should have internal parametrization as similar as possible. * * @param size the number of cell the matrix shall have. * @return a new empty matrix of the same dynamic type. */ public DoubleMatrix1D like(int size) { return new SparseDoubleMatrix1D(size); } /**
/** * Construct and returns a new empty matrix <i>of the same dynamic type</i> as the receiver, having the specified size. * For example, if the receiver is an instance of type <tt>DenseDoubleMatrix1D</tt> the new matrix must also be of type <tt>DenseDoubleMatrix1D</tt>, * if the receiver is an instance of type <tt>SparseDoubleMatrix1D</tt> the new matrix must also be of type <tt>SparseDoubleMatrix1D</tt>, etc. * In general, the new matrix should have internal parametrization as similar as possible. * * @param size the number of cell the matrix shall have. * @return a new empty matrix of the same dynamic type. */ public DoubleMatrix1D like(int size) { return new SparseDoubleMatrix1D(size); } /**
/** * Construct and returns a new 1-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>DenseDoubleMatrix2D</tt> the new matrix must be of type <tt>DenseDoubleMatrix1D</tt>, * if the receiver is an instance of type <tt>SparseDoubleMatrix2D</tt> the new matrix must be of type <tt>SparseDoubleMatrix1D</tt>, etc. * * @param size the number of cells the matrix shall have. * @return a new matrix of the corresponding dynamic type. */ public DoubleMatrix1D like1D(int size) { return new SparseDoubleMatrix1D(size); } protected void remove(int row, int index) {
/** * Construct and returns a new 1-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>DenseDoubleMatrix2D</tt> the new matrix must be of type <tt>DenseDoubleMatrix1D</tt>, * if the receiver is an instance of type <tt>SparseDoubleMatrix2D</tt> the new matrix must be of type <tt>SparseDoubleMatrix1D</tt>, etc. * * @param size the number of cells the matrix shall have. * @return a new matrix of the corresponding dynamic type. */ public DoubleMatrix1D like1D(int size) { return new SparseDoubleMatrix1D(size); } /**
/** * Construct and returns a new 1-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>DenseDoubleMatrix2D</tt> the new matrix must be of type <tt>DenseDoubleMatrix1D</tt>, * if the receiver is an instance of type <tt>SparseDoubleMatrix2D</tt> the new matrix must be of type <tt>SparseDoubleMatrix1D</tt>, etc. * * @param size the number of cells the matrix shall have. * @return a new matrix of the corresponding dynamic type. */ public DoubleMatrix1D like1D(int size) { return new SparseDoubleMatrix1D(size); } /**
/** * Construct and returns a new 1-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>DenseDoubleMatrix2D</tt> the new matrix must be of type <tt>DenseDoubleMatrix1D</tt>, * if the receiver is an instance of type <tt>SparseDoubleMatrix2D</tt> the new matrix must be of type <tt>SparseDoubleMatrix1D</tt>, etc. * * @param size the number of cells the matrix shall have. * @return a new matrix of the corresponding dynamic type. */ public DoubleMatrix1D like1D(int size) { return new SparseDoubleMatrix1D(size); } /**
/** * Construct and returns a new 1-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>DenseDoubleMatrix2D</tt> the new matrix must be of type <tt>DenseDoubleMatrix1D</tt>, * if the receiver is an instance of type <tt>SparseDoubleMatrix2D</tt> the new matrix must be of type <tt>SparseDoubleMatrix1D</tt>, etc. * * @param size the number of cells the matrix shall have. * @return a new matrix of the corresponding dynamic type. */ public DoubleMatrix1D like1D(int size) { return new SparseDoubleMatrix1D(size); } protected void remove(int row, int index) {