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