Global data and functions.
Base class of all other classes of ABACUS.
AbacusGlobal * glob_
A pointer to the corresponding global object.
SparVec(AbacusGlobal *glob, int size, int *s, double *c, double reallocFac=10.0)
Creates a sparse vector and initializes support and coefficients.
void clear()
Removes all nonzeros from the sparse vector.
int size() const
Returns the maximal length of the sparse vector.
double origCoeff(int i) const
void copy(const SparVec &vec)
Copies vector vec.
void leftShift(ArrayBuffer< int > &del)
Deletes the elements listed in a buffer from the sparse vector.
int size_
The maximal number of nonzero coefficients which can be stored without reallocation.
int nnz_
The number of stored elements ("nonzeros").
void realloc(int newSize)
Reallocates the sparse vector to a given length.
double coeff(int i) const
void rangeCheck(int i) const
Checks whether i is a valid index.
int * support_
The array storing the nonzero variables.
void insert(int s, double c)
Adds a new support/coefficient pair to the vector.
void rename(Array< int > &newName)
Replaces the index of the support by new names.
int nnz() const
Returns the number of nonzero elements.
SparVec(AbacusGlobal *glob, int size, const Array< int > &s, const Array< double > &c, double reallocFac=10.0)
Creates a sparse vector and initializes support and coefficients.
~SparVec()
The destructor.
SparVec(AbacusGlobal *glob, int size, double reallocFac=10.0)
Creates an empty sparse vector.
SparVec & operator=(const SparVec &rhs)
The assignment operator.
void realloc()
Increases the size of the sparse vector by reallocFac_ percent of the original size.
double norm()
Returns the Euclidean norm of the sparse vector.
double * coeff_
The array storing the corresponding nonzero coefficients.
friend std::ostream & operator<<(std::ostream &out, const SparVec &rhs)
The output operator.
SparVec(const SparVec &rhs)
Copy constructor.
double reallocFac_
If a new element is inserted but the sparse vector is full, then its size is increased by reallocFac_...
An array that keeps track of the number of inserted elements; also usable as an efficient stack.
The parameterized class Array implements dynamic arrays of type E.
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()