CXSC  A C++ Class Library for Extended Scientific Computing
2.5.4

A sparse complex vector. More...
#include <scvector.hpp>
Public Member Functions  
real  density () const 
Returns the density of the vector (the number of non zero elements divided by the number of elements)  
void  dropzeros () 
Erases explicitly stored zeros from the data structure.  
int  get_nnz () const 
Returns the number of non zero elements of this vector (note that this includes explicitly stored zeros)  
const complex  operator() (const int i) const 
Returns a copy of the ith (according to the currently used indexing) element of the vector.  
scvector  operator() (const intvector &per) 
Returns a vector whose elemnts are rearranged according to a given permutation vector.  
scvector  operator() (const intmatrix &P) 
Returns a vector whose elemnts are rearranged according to a given permutation matrix.  
scvector_slice  operator() (const int, const int) 
Returns a slice of the vector from the ith to the jth (according to the currently used indexing) element.  
scvector &  operator*= (const real &s) 
Operator for multiplication with a scalar, result is assigned to the vector.  
scvector &  operator*= (const complex &s) 
Operator for multiplication with a scalar, result is assigned to the vector.  
scvector &  operator+= (const rvector &v) 
Operator for elementwise addition with a vector, result is assigned to the vector.  
scvector &  operator+= (const cvector &v) 
Operator for elementwise addition with a vector, result is assigned to the vector.  
scvector &  operator+= (const rvector_slice &v) 
Operator for elementwise addition with a vector, result is assigned to the vector.  
scvector &  operator+= (const cvector_slice &v) 
Operator for elementwise addition with a vector, result is assigned to the vector.  
scvector &  operator+= (const srvector &v) 
Operator for elementwise addition with a vector, result is assigned to the vector.  
scvector &  operator+= (const scvector &v) 
Operator for elementwise addition with a vector, result is assigned to the vector.  
scvector &  operator+= (const srvector_slice &) 
Operator for elementwise addition with a vector, result is assigned to the vector.  
scvector &  operator+= (const scvector_slice &) 
Operator for elementwise addition with a vector, result is assigned to the vector.  
scvector &  operator= (const rvector &v) 
Operator for elementwise subtraction with a vector, result is assigned to the vector.  
scvector &  operator= (const cvector &v) 
Operator for elementwise subtraction with a vector, result is assigned to the vector.  
scvector &  operator= (const rvector_slice &v) 
Operator for elementwise subtraction with a vector, result is assigned to the vector.  
scvector &  operator= (const cvector_slice &v) 
Operator for elementwise subtraction with a vector, result is assigned to the vector.  
scvector &  operator= (const srvector &v) 
Operator for elementwise subtraction with a vector, result is assigned to the vector.  
scvector &  operator= (const scvector &v) 
Operator for elementwise subtraction with a vector, result is assigned to the vector.  
scvector &  operator= (const srvector_slice &) 
Operator for elementwise subtraction with a vector, result is assigned to the vector.  
scvector &  operator= (const scvector_slice &) 
Operator for elementwise subtraction with a vector, result is assigned to the vector.  
scvector &  operator/= (const real &s) 
Operator for division of each element of the vector with a scalar, result is assigned to the vector.  
scvector &  operator/= (const complex &s) 
Operator for division of each element of the vector with a scalar, result is assigned to the vector.  
scvector &  operator= (const srvector &v) 
Assigns a sparse real vector to a sparse complex vector.  
scvector &  operator= (const real &v) 
Assigns v to all elements of the vector (resulting in a dense vector!)  
scvector &  operator= (const complex &v) 
Assigns v to all elements of the vector (resulting in a dense vector!)  
scvector &  operator= (const rvector &v) 
Assign the dense vector v to a sparse vector. Only the non zero elements of v are used.  
scvector &  operator= (const cvector &v) 
Assign the dense vector v to a sparse vector. Only the non zero elements of v are used.  
scvector &  operator= (const rvector_slice &v) 
Assign the dense vector slice v to a sparse vector. Only the non zero elements of v are used.  
scvector &  operator= (const cvector_slice &v) 
Assign the dense vector slice v to a sparse vector. Only the non zero elements of v are used.  
scvector &  operator= (const scvector_slice &) 
Assign the sparse vector slice v to a sparse vector.  
scvector &  operator= (const srvector_slice &) 
Assign the sparse vector slice v to a sparse vector.  
complex &  operator[] (const int i) 
Returns a reference to the ith (according to the currently used indexing) element of the vector.  
complex  operator[] (const int i) const 
Returns a copy of the ith (according to the currently used indexing) element of the vector.  
std::vector< int > &  row_indices () 
Returns a reference to the STLvector storing the row indices of the non zero elements.  
const std::vector< int > &  row_indices () const 
Returns a reference to the STLvector storing the row indices of the non zero elements.  
scvector ()  
Default constructor, creates an empty vector of size 0.  
scvector (const int s)  
Constructor for creating an empty vector of size s.  
scvector (const int s, const int b)  
Constructor for creating an empty vector of size s and reserving memory for b elements.  
scvector (const cvector &v)  
Constructor for creating a sparse vector our of a dense vector v. Only the nonzero elements of v are stored explicitly.  
scvector (const rvector &v)  
Constructor for creating a sparse vector our of a dense vector v. Only the nonzero elements of v are stored explicitly.  
scvector (const int n, const int nnz, const intvector &index, const cvector &values)  
Creates a sparse vector of dimension n with nnz non zeros, who are defined by the elements of index and values.  
scvector (const int n, const int nnz, const int *index, const complex *values)  
Creates a sparse vector of dimension n with nnz non zeros, who are defined by the elements of index and values.  
scvector (const srvector &v)  
Constructor for creating a sparse complex vector our of a sparse real vector.  
scvector (const srvector_slice &)  
Creates a sparse vector out of a sparse vector slice.  
scvector (const scvector_slice &)  
Creates a sparse vector out of a sparse vector slice.  
scvector (const srmatrix_subv &A)  
Creates a sparse vector out of a row or column of a sparse matrix.  
scvector (const scmatrix_subv &A)  
Creates a sparse vector out of a row or column of a sparse matrix.  
std::vector< complex > &  values () 
Returns a reference to the STLvector storing the values of the non zero elements.  
const std::vector< complex > &  values () const 
Returns a reference to the STLvector storing the values of the non zero elements.  
Friends  
srvector  abs (const scvector &) 
Returns the vector of componentwise absolute values of v.  
scvector  diam (const scivector &) 
Computes the diameter of v.  
scvector  diam (const scivector_slice &) 
Computes the diameter of v.  
srvector  Im (const scvector &) 
Returns the imaginary part of the complex vector v.  
scvector  Inf (const scivector &) 
Returns the infimum of the complex interval vector as a new sparse point vector.  
int  Lb (const scvector &) 
Returns the lower index bound of the vector v.  
scvector  mid (const scivector &) 
Compute the midpoint vector of v.  
scvector  mid (const scivector_slice &) 
Computes the midpoint vector of v.  
srvector  Re (const scvector &) 
Returns the real part of the complex vector v.  
void  SetLb (scvector &, const int) 
Sets the lower index bound of the vector v to i.  
void  SetUb (scvector &, const int) 
Sets the upper index bound of the vector v to i.  
scvector  Sup (const scivector &) 
Returns the supremum of the complex interval vector as a new sparse point vector.  
int  Ub (const scvector &) 
Returns the upper index bound of the vector v.  
int  VecLen (const scvector &) 
Returns the length of the vector (the dimension) 
A sparse complex vector.
This data type represents a sparse complex vector. Only the non zero elements are stored explicitly with their value and the respective index. All operators are overloaded to take advantage of the sparsity.
Definition at line 58 of file scvector.hpp.
const complex cxsc::scvector::operator()  (  const int  i  )  const [inline] 
Returns a copy of the ith (according to the currently used indexing) element of the vector.
If the ith element is explicitly stored, a copy of this value is returned. Otherwise, 0.0 will be returned. Unlike with the []operator, the data structure remains unchanged either way. Thus this operator should always be used for readonly access to the elements of a sparse vector.
Definition at line 282 of file scvector.hpp.
Returns a vector whose elemnts are rearranged according to a given permutation vector.
For a permutation vector p with p[Lb(p)+i]=j, the jth element of the given sparse vector will be the ith element of the returned permuted vector.
Definition at line 300 of file scvector.hpp.
Returns a vector whose elemnts are rearranged according to a given permutation matrix.
For a given sparse vector x and permutation matrix P, this operator return the result of P*x. This operator is more efficient than explicitly computing P*x, since P is transformed into a permutation vector and the permutation ist performed directly, without explicitly computing P*x.
Definition at line 323 of file scvector.hpp.
scvector_slice cxsc::scvector::operator()  (  const int  i, 
const int  j  
)  [inline] 
Returns a slice of the vector from the ith to the jth (according to the currently used indexing) element.
This operator can be used for read and write access to a slice of the sparse vector.
Definition at line 1585 of file scvector.hpp.
complex& cxsc::scvector::operator[]  (  const int  i  )  [inline] 
Returns a reference to the ith (according to the currently used indexing) element of the vector.
If the ith element is explicitly stored, a reference to the value is returned. If is not explicitly stored, it will be added to the data structure as a zero element. The returned reference then points to this new element. Hence ths []operator should only be used for write access to the elements of a sparse vector. Use the ()operator for read access.
Definition at line 248 of file scvector.hpp.
complex cxsc::scvector::operator[]  (  const int  i  )  const [inline] 
Returns a copy of the ith (according to the currently used indexing) element of the vector.
If the ith element is explicitly stored, a copy to the value is returned. If is not explicitly stored, zero will be returned. This is the constVersion of this operator, added for convenience. It is suggested to use thei ()operator for read access.
Definition at line 270 of file scvector.hpp.
std::vector<int>& cxsc::scvector::row_indices  (  )  [inline] 
Returns a reference to the STLvector storing the row indices of the non zero elements.
This function is provided to allow easy interfacing to other software interfaces and efficient implementation of sparse algorithms. The user has to take care that the data remains consistent (the ith element of the STLvector storing the indices refers to the ith element of the STLvector storing the values of the elements). Note that the stored indices are always 0based, independent of the starting index set in CXSC.
Definition at line 147 of file scvector.hpp.
Referenced by cxsc::abs().
const std::vector<int>& cxsc::scvector::row_indices  (  )  const [inline] 
Returns a reference to the STLvector storing the row indices of the non zero elements.
This function is provided to allow easy interfacing to other software interfaces and efficient implementation of sparse algorithms. The user has to take care that the data remains consistent (the ith element of the STLvector storing the indices refers to the ith element of the STLvector storing the values of the elements). Note that the stored indices are always 0based, independent of the starting index set in CXSC.
Definition at line 165 of file scvector.hpp.
std::vector<complex>& cxsc::scvector::values  (  )  [inline] 
Returns a reference to the STLvector storing the values of the non zero elements.
This function is provided to allow easy interfacing to other software interfaces and efficient implementation of sparse algorithms. The user has to take care that the data remains consistent (the ith element of the STLvector storing the indices refers to the ith element of the STLvector storing the values of the elements).
Definition at line 155 of file scvector.hpp.
Referenced by cxsc::abs().
const std::vector<complex>& cxsc::scvector::values  (  )  const [inline] 
Returns a reference to the STLvector storing the values of the non zero elements.
This function is provided to allow easy interfacing to other software interfaces and efficient implementation of sparse algorithms. The user has to take care that the data remains consistent (the ith element of the STLvector storing the indices refers to the ith element of the STLvector storing the values of the elements).
Definition at line 173 of file scvector.hpp.
void SetLb  (  scvector &  v, 
const int  i  
)  [friend] 
Sets the lower index bound of the vector v to i.
After setting the lower index bound to i, the indexing of the vector is ibased.
Definition at line 492 of file scvector.hpp.
void SetUb  (  scvector &  v, 
const int  j  
)  [friend] 
Sets the upper index bound of the vector v to i.
After setting the upper index bound to i, the indexing of the vector of dimension n is (in+1)based.
Definition at line 501 of file scvector.hpp.