C-XSC - A C++ Class Library for Extended Scientific Computing
2.5.4
|
A sparse real vector. More...
#include <srvector.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 real | operator() (const int i) const |
Returns a copy of the i-th (according to the currently used indexing) element of the vector. | |
srvector_slice | operator() (const int i, const int j) |
Returns a slice of the vector from the i-th to the j-th (according to the currently used indexing) element. | |
srvector | operator() (const intvector &per) |
Returns a vector whose elemnts are rearranged according to a given permutation vector. | |
srvector | operator() (const intmatrix &P) |
Returns a vector whose elemnts are rearranged according to a given permutation matrix. | |
srvector & | operator*= (const real &s) |
Operator for multiplication with a scalar, result is assigned to the vector. | |
srvector & | operator+= (const rvector &v) |
Operator for element-wise addition with a vector, result is assigned to the vector. | |
srvector & | operator+= (const rvector_slice &v) |
Operator for element-wise addition with a vector, result is assigned to the vector. | |
srvector & | operator+= (const srvector &v) |
Operator for element-wise addition with a vector, result is assigned to the vector. | |
srvector & | operator+= (const srvector_slice &) |
Operator for element-wise addition with a vector, result is assigned to the vector. | |
srvector & | operator-= (const rvector &v) |
Operator for element-wise subtraction with a vector, result is assigned to the vector. | |
srvector & | operator-= (const rvector_slice &v) |
Operator for element-wise subtraction with a vector, result is assigned to the vector. | |
srvector & | operator-= (const srvector &v) |
Operator for element-wise subtraction with a vector, result is assigned to the vector. | |
srvector & | operator-= (const srvector_slice &) |
Operator for element-wise subtraction with a vector, result is assigned to the vector. | |
srvector & | operator/= (const real &s) |
Operator for division of each element of the vector with a scalar, result is assigned to the vector. | |
srvector & | operator= (const real &v) |
Assigns v to all elements of the vector (resulting in a dense vector!) | |
srvector & | operator= (const rvector &v) |
Assign the dense vector v to a sparse vector. Only the non zero elements of v are used. | |
srvector & | operator= (const rvector_slice &v) |
Assign the dense vector slice v to a sparse vector. Only the non zero elements of v are used. | |
srvector & | operator= (const srvector_slice &) |
Assign the sparse vector slice v to a sparse vector. | |
real & | operator[] (const int i) |
Returns a reference to the i-th (according to the currently used indexing) element of the vector. | |
real | operator[] (const int i) const |
Returns a copy of the i-th (according to the currently used indexing) element of the vector. | |
std::vector< int > & | row_indices () |
Returns a reference to the STL-vector storing the row indices of the non zero elements. | |
const std::vector< int > & | row_indices () const |
Returns a reference to the STL-vector storing the row indices of the non zero elements. | |
srvector () | |
Default constructor, creates an empty vector of size 0. | |
srvector (const int s) | |
Constructor for creating an empty vector of size s. | |
srvector (const int s, const int b) | |
Constructor for creating an empty vector of size s and reserving memory for b elements. | |
srvector (const rvector &v) | |
Constructor for creating a sparse vector our of a dense vector v. Only the non-zero elements of v are stored explicitly. | |
srvector (const int n, const int nnz, const intvector &index, const rvector &values) | |
Creates a sparse vector of dimension n with nnz non zeros, who are defined by the elements of index and values. | |
srvector (const int n, const int nnz, const int *index, const real *values) | |
Creates a sparse vector of dimension n with nnz non zeros, who are defined by the elements of index and values. | |
srvector (const srvector_slice &) | |
Creates a sparse vector out of a sparse vector slice. | |
srvector (const srmatrix_subv &A) | |
Creates a sparse vector out of a row or column of a sparse matrix. | |
std::vector< real > & | values () |
Returns a reference to the STL-vector storing the values of the non zero elements. | |
const std::vector< real > & | values () const |
Returns a reference to the STL-vector storing the values of the non zero elements. | |
Friends | |
srvector | abs (const srvector &) |
Returns the vector whose elements are the respective absolute values of the elements of v. | |
srvector | absmax (const sivector &) |
Computes the component-wise maximum absolute values for a vector v. | |
srvector | absmin (const sivector &) |
Computes the component-wise minimum absolute values for a vector v. | |
srvector | diam (const sivector &) |
Computes the diameter of v. | |
srvector | diam (const sivector_slice &) |
Computes the diameter of v. | |
srvector | Im (const scvector &) |
Returns the imaginary part of the complex vector v. | |
srvector | Inf (const sivector &) |
Returns the infimum of the interval vector as a new sparse point vector. | |
srvector | InfIm (const scivector &) |
Returns the infimum of the imaginary part of the complex interval vector as a new sparse point vector. | |
srvector | InfRe (const scivector &) |
Returns the infimum of the real part of the complex interval vector as a new sparse point vector. | |
int | Lb (const srvector &) |
Returns the lower index bound of the vector v. | |
srvector | mid (const sivector &) |
Compute the midpoint vector of v. | |
srvector | mid (const sivector_slice &) |
Computes the midpoint vector of v. | |
srvector | Re (const scvector &) |
Returns the real part of the complex vector v. | |
void | SetLb (srvector &, const int) |
Sets the lower index bound of the vector v to i. | |
void | SetUb (srvector &, const int) |
Sets the upper index bound of the vector v to i. | |
srvector | Sup (const sivector &) |
Returns the supremum of the interval vector as a new sparse point vector. | |
srvector | SupIm (const scivector &) |
Returns the supremum of the imaginary part of the complex interval vector as a new sparse point vector. | |
srvector | SupRe (const scivector &) |
Returns the supremum of the real part of the complex interval vector as a new sparse point vector. | |
int | Ub (const srvector &) |
Returns the upper index bound of the vector v. | |
int | VecLen (const srvector &) |
Returns the length of the vector (the dimension) |
A sparse real vector.
This data type represents a sparse real 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 srvector.hpp.
const real cxsc::srvector::operator() | ( | const int | i | ) | const [inline] |
Returns a copy of the i-th (according to the currently used indexing) element of the vector.
If the i-th 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 read-only access to the elements of a sparse vector.
Definition at line 236 of file srvector.hpp.
srvector_slice cxsc::srvector::operator() | ( | const int | i, |
const int | j | ||
) | [inline] |
Returns a slice of the vector from the i-th to the j-th (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 1100 of file srvector.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 j-th element of the given sparse vector will be the i-th element of the returned permuted vector.
Definition at line 259 of file srvector.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 282 of file srvector.hpp.
real& cxsc::srvector::operator[] | ( | const int | i | ) | [inline] |
Returns a reference to the i-th (according to the currently used indexing) element of the vector.
If the i-th 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 202 of file srvector.hpp.
real cxsc::srvector::operator[] | ( | const int | i | ) | const [inline] |
Returns a copy of the i-th (according to the currently used indexing) element of the vector.
If the i-th element is explicitly stored, a copy to the value is returned. If is not explicitly stored, zero will be returned. This is the const-Version of this operator, added for convenience. It is suggested to use thei ()-operator for read access.
Definition at line 224 of file srvector.hpp.
std::vector<int>& cxsc::srvector::row_indices | ( | ) | [inline] |
Returns a reference to the STL-vector 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 i-th element of the STL-vector storing the indices refers to the i-th element of the STL-vector storing the values of the elements). Note that the stored indices are always 0-based, independent of the starting index set in C-XSC.
Definition at line 127 of file srvector.hpp.
Referenced by cxsc::abs().
const std::vector<int>& cxsc::srvector::row_indices | ( | ) | const [inline] |
Returns a reference to the STL-vector 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 i-th element of the STL-vector storing the indices refers to the i-th element of the STL-vector storing the values of the elements). Note that the stored indices are always 0-based, independent of the starting index set in C-XSC.
Definition at line 146 of file srvector.hpp.
std::vector<real>& cxsc::srvector::values | ( | ) | [inline] |
Returns a reference to the STL-vector 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 i-th element of the STL-vector storing the indices refers to the i-th element of the STL-vector storing the values of the elements).
Definition at line 136 of file srvector.hpp.
Referenced by cxsc::abs().
const std::vector<real>& cxsc::srvector::values | ( | ) | const [inline] |
Returns a reference to the STL-vector 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 i-th element of the STL-vector storing the indices refers to the i-th element of the STL-vector storing the values of the elements).
Definition at line 155 of file srvector.hpp.
void SetLb | ( | srvector & | 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 i-based.
Definition at line 402 of file srvector.hpp.
void SetUb | ( | srvector & | 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 (i-n+1)-based.
Definition at line 411 of file srvector.hpp.