/** * Build a vector with known the sparseness (for advanced use only). * * @param field Field to which the elements belong. * @param dimension Size of the vector. * @param expectedSize Expected number of non-zero entries. */ public SparseFieldVector(Field<T> field, int dimension, int expectedSize) { this.field = field; virtualSize = dimension; entries = new OpenIntToFieldHashMap<T>(field,expectedSize); }
/** * Create a matrix with no data. * * @param field Field to which the elements belong. */ public SparseFieldMatrix(final Field<T> field) { super(field); rows = 0; columns= 0; entries = new OpenIntToFieldHashMap<T>(field); }
/** * Construct a vector of zeroes. * * @param field Field to which the elements belong. * @param dimension Size of the vector. */ public SparseFieldVector(Field<T> field, int dimension) { this.field = field; virtualSize = dimension; entries = new OpenIntToFieldHashMap<T>(field); }
/** * Create a new SparseFieldMatrix<T> with the supplied row and column * dimensions. * * @param field Field to which the elements belong. * @param rowDimension Number of rows in the new matrix. * @param columnDimension Number of columns in the new matrix. * @throws org.apache.commons.math3.exception.NotStrictlyPositiveException * if row or column dimension is not positive. */ public SparseFieldMatrix(final Field<T> field, final int rowDimension, final int columnDimension) { super(field, rowDimension, columnDimension); this.rows = rowDimension; this.columns = columnDimension; entries = new OpenIntToFieldHashMap<T>(field); }
/** * Build a resized vector, for use with append. * * @param v Original vector * @param resize Amount to add. */ protected SparseFieldVector(SparseFieldVector<T> v, int resize) { field = v.field; virtualSize = v.getDimension() + resize; entries = new OpenIntToFieldHashMap<T>(v.entries); }
/** * Copy constructor. * * @param v Instance to copy. */ public SparseFieldVector(SparseFieldVector<T> v) { field = v.field; virtualSize = v.getDimension(); entries = new OpenIntToFieldHashMap<T>(v.getEntries()); }
/** * Create from a Field array. * Only non-zero entries will be stored. * * @param field Field to which the elements belong. * @param values Set of values to create from. * @exception NullArgumentException if values is null */ public SparseFieldVector(Field<T> field, T[] values) throws NullArgumentException { MathUtils.checkNotNull(values); this.field = field; virtualSize = values.length; entries = new OpenIntToFieldHashMap<T>(field); for (int key = 0; key < values.length; key++) { T value = values[key]; entries.put(key, value); } }
/** * Copy constructor. * * @param other Instance to copy. */ public SparseFieldMatrix(SparseFieldMatrix<T> other) { super(other.getField(), other.getRowDimension(), other.getColumnDimension()); rows = other.getRowDimension(); columns = other.getColumnDimension(); entries = new OpenIntToFieldHashMap<T>(other.entries); }
/** * Generic copy constructor. * * @param other Instance to copy. */ public SparseFieldMatrix(FieldMatrix<T> other){ super(other.getField(), other.getRowDimension(), other.getColumnDimension()); rows = other.getRowDimension(); columns = other.getColumnDimension(); entries = new OpenIntToFieldHashMap<T>(getField()); for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { setEntry(i, j, other.getEntry(i, j)); } } }
/** * Build a vector with known the sparseness (for advanced use only). * * @param field Field to which the elements belong. * @param dimension Size of the vector. * @param expectedSize Expected number of non-zero entries. */ public SparseFieldVector(Field<T> field, int dimension, int expectedSize) { this.field = field; virtualSize = dimension; entries = new OpenIntToFieldHashMap<T>(field,expectedSize); }
/** * Construct a vector of zeroes. * * @param field Field to which the elements belong. * @param dimension Size of the vector. */ public SparseFieldVector(Field<T> field, int dimension) { this.field = field; virtualSize = dimension; entries = new OpenIntToFieldHashMap<T>(field); }
/** * Create a matrix with no data. * * @param field Field to which the elements belong. */ public SparseFieldMatrix(final Field<T> field) { super(field); rows = 0; columns= 0; entries = new OpenIntToFieldHashMap<T>(field); }
/** * Create a new SparseFieldMatrix<T> with the supplied row and column * dimensions. * * @param field Field to which the elements belong. * @param rowDimension Number of rows in the new matrix. * @param columnDimension Number of columns in the new matrix. * @throws org.apache.commons.math3.exception.NotStrictlyPositiveException * if row or column dimension is not positive. */ public SparseFieldMatrix(final Field<T> field, final int rowDimension, final int columnDimension) { super(field, rowDimension, columnDimension); this.rows = rowDimension; this.columns = columnDimension; entries = new OpenIntToFieldHashMap<T>(field); }
/** * Build a resized vector, for use with append. * * @param v Original vector * @param resize Amount to add. */ protected SparseFieldVector(SparseFieldVector<T> v, int resize) { field = v.field; virtualSize = v.getDimension() + resize; entries = new OpenIntToFieldHashMap<T>(v.entries); }
/** * Copy constructor. * * @param v Instance to copy. */ public SparseFieldVector(SparseFieldVector<T> v) { field = v.field; virtualSize = v.getDimension(); entries = new OpenIntToFieldHashMap<T>(v.getEntries()); }
/** * Create from a Field array. * Only non-zero entries will be stored. * * @param field Field to which the elements belong. * @param values Set of values to create from. * @exception NullArgumentException if values is null */ public SparseFieldVector(Field<T> field, T[] values) throws NullArgumentException { MathUtils.checkNotNull(values); this.field = field; virtualSize = values.length; entries = new OpenIntToFieldHashMap<T>(field); for (int key = 0; key < values.length; key++) { T value = values[key]; entries.put(key, value); } }
/** * Copy constructor. * * @param other Instance to copy. */ public SparseFieldMatrix(SparseFieldMatrix<T> other) { super(other.getField(), other.getRowDimension(), other.getColumnDimension()); rows = other.getRowDimension(); columns = other.getColumnDimension(); entries = new OpenIntToFieldHashMap<T>(other.entries); }
/** * Generic copy constructor. * * @param other Instance to copy. */ public SparseFieldMatrix(FieldMatrix<T> other){ super(other.getField(), other.getRowDimension(), other.getColumnDimension()); rows = other.getRowDimension(); columns = other.getColumnDimension(); entries = new OpenIntToFieldHashMap<T>(getField()); for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { setEntry(i, j, other.getEntry(i, j)); } } }