AbstractLinAlgPack: C++ Interfaces For Vectors, Matrices And Related Linear Algebra Objects  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | List of all members
AbstractLinAlgPack::SparseVectorSlice< T_Element > Class Template Reference

Sparse Vector Slice class template. More...

#include <AbstractLinAlgPack_SparseVectorClassDecl.hpp>

Inheritance diagram for AbstractLinAlgPack::SparseVectorSlice< T_Element >:
Inheritance graph
[legend]

Public Member Functions

void bind (SparseVectorSlice svs)
 Constructs a sparse vector slice view from another sparse vector slice. More...
 
EOverLap overlap (const SparseVectorSlice< T_Element > &sv) const
 

Public types.

typedef T_Element element_type
 
typedef
AbstractLinAlgPack::size_type 
size_type
 
typedef ptrdiff_t difference_type
 
typedef element_typeiterator
 
typedef const element_typeconst_iterator
 
typedef std::reverse_iterator
< iterator
reverse_iterator
 
typedef std::reverse_iterator
< const_iterator
const_reverse_iterator
 
typedef
SparseVectorUtilityPack::DoesNotExistException 
DoesNotExistException
 
typedef
SparseVectorUtilityPack::NotSortedException 
NotSortedException
 

Constuctors

The default copy constructor is allowed since it has the proper semantics.

 SparseVectorSlice (element_type ele[], size_type nz, difference_type offset, size_type size, bool assume_sorted=false)
 Constructs a sparse vector slice from an array of elements. More...
 

Sparse Vector Templated interface for linear algebra operations

size_type dim () const
 Return the number of elements in the full vector. More...
 
size_type nz () const
 Return the number of non-zero elements. More...
 
difference_type offset () const
 Return the offset for the indexes (ith real index = begin()[i-1]->index() + offset()# , for i = 1,,,nz()#) More...
 
bool is_sorted () const
 Return true if the sequence is assumed sorted. More...
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
reverse_iterator rbegin ()
 
const_reverse_iterator rbegin () const
 
reverse_iterator rend ()
 
const_reverse_iterator rend () const
 

Lookup an element.

If element v(i) exists, then a pointer to the element will be returned. If v(i) does not exist, then the NULL pointer will be returned.

If i is out of range then a std::out_of_range exception will be thrown.

If the elements are sored then this operation is O(log(nz)) for a binary search. Otherwise, it requries a O(nz) linear search.

element_typelookup_element (size_type i)
 
const element_typelookup_element (size_type i) const
 

Creating a slice (subregion) of the sparse vector

SparseVectorSlice< T_Element > & operator() ()
 
const SparseVectorSlice
< T_Element > & 
operator() () const
 
SparseVectorSliceoperator& ()
 Allow address to be taken of an rvalue of this object. More...
 
const SparseVectorSliceoperator& () const
 
SparseVectorSlice< T_Element > operator() (const Range1D &rng)
 
const SparseVectorSlice
< T_Element > 
operator() (const Range1D &rng) const
 
SparseVectorSlice< T_Element > operator() (size_type lbound, size_type ubound)
 
const SparseVectorSlice
< T_Element > 
operator() (size_type lbound, size_type ubound) const
 

Detailed Description

template<class T_Element>
class AbstractLinAlgPack::SparseVectorSlice< T_Element >

Sparse Vector Slice class template.

This is a class for abstracting a region of a sparse vector stored as an array of elements of a templated type. The required inteface for the type of these elements is given in the SparseVector documentation.

Here if nz() == 0 then begin() == end() so it is safe to set up loops in the form of:

for(SparseVectorSlice<T>::const_iterator itr = sv.begin(); itr != sv.end(); ++itr) // some access of *itr.

Note that if nz()==0 then begin() may not point to a valid object so don't do it.

The default copy constructor is allowed but the default constructor and assignment operator functions are not.

Definition at line 102 of file AbstractLinAlgPack_SparseVectorClassDecl.hpp.

Member Typedef Documentation

template<class T_Element>
typedef T_Element AbstractLinAlgPack::SparseVectorSlice< T_Element >::element_type
template<class T_Element>
typedef AbstractLinAlgPack::size_type AbstractLinAlgPack::SparseVectorSlice< T_Element >::size_type
template<class T_Element>
typedef ptrdiff_t AbstractLinAlgPack::SparseVectorSlice< T_Element >::difference_type
template<class T_Element>
typedef element_type* AbstractLinAlgPack::SparseVectorSlice< T_Element >::iterator
template<class T_Element>
typedef const element_type* AbstractLinAlgPack::SparseVectorSlice< T_Element >::const_iterator
template<class T_Element>
typedef std::reverse_iterator<iterator> AbstractLinAlgPack::SparseVectorSlice< T_Element >::reverse_iterator
template<class T_Element>
typedef std::reverse_iterator<const_iterator> AbstractLinAlgPack::SparseVectorSlice< T_Element >::const_reverse_iterator

Constructor & Destructor Documentation

template<class T_Element >
AbstractLinAlgPack::SparseVectorSlice< T_Element >::SparseVectorSlice ( element_type  ele[],
size_type  nz,
difference_type  offset,
size_type  size,
bool  assume_sorted = false 
)
inline

Constructs a sparse vector slice from an array of elements.

Here a pointer to an array of elements is used instead of a pointer to std::vector<T_Ele,T_Alloc> in order to insulated this class from the type of allocator used since this information is not needed.

A sparse vector slice with no nonzero elements can be constructed by setting nz == 0;

Preconditions:

  • #ele != 0#
  • #size >= nz#
Parameters
elepointer to array of elements (length nz#)
offsetoffset for the indexes of the elements. index = ele[i].index() + offset
sizenumber of elements in the full vector
nznumber of non-zero elements in vector

Definition at line 1012 of file AbstractLinAlgPack_SparseVectorClassDecl.hpp.

Member Function Documentation

template<class T_Element >
void AbstractLinAlgPack::SparseVectorSlice< T_Element >::bind ( SparseVectorSlice< T_Element >  svs)
inline

Constructs a sparse vector slice view from another sparse vector slice.

Definition at line 1018 of file AbstractLinAlgPack_SparseVectorClassDecl.hpp.

template<class T_Element>
EOverLap AbstractLinAlgPack::SparseVectorSlice< T_Element >::overlap ( const SparseVectorSlice< T_Element > &  sv) const

Returns the degree of memory overlap of this SparseVector and a SparseVectorSlice.

Returns
{description} [NO_OVERLAP] There is no memory overlap between this and sv [SOME_OVERLAP] There is some memory locations that this and sv share [SAME_MEM] The DVectorSlice objects this and sv share the exact same memory locations. {description}

Definition at line 422 of file AbstractLinAlgPack_SparseVectorClassDef.hpp.

template<class T_Element >
SparseVectorSlice< T_Element >::size_type AbstractLinAlgPack::SparseVectorSlice< T_Element >::dim ( ) const
inline

Return the number of elements in the full vector.

Definition at line 1028 of file AbstractLinAlgPack_SparseVectorClassDecl.hpp.

template<class T_Element >
SparseVectorSlice< T_Element >::size_type AbstractLinAlgPack::SparseVectorSlice< T_Element >::nz ( ) const
inline

Return the number of non-zero elements.

Definition at line 1033 of file AbstractLinAlgPack_SparseVectorClassDecl.hpp.

template<class T_Element >
SparseVectorSlice< T_Element >::difference_type AbstractLinAlgPack::SparseVectorSlice< T_Element >::offset ( ) const
inline

Return the offset for the indexes (ith real index = begin()[i-1]->index() + offset()# , for i = 1,,,nz()#)

Definition at line 1038 of file AbstractLinAlgPack_SparseVectorClassDecl.hpp.

template<class T_Element >
bool AbstractLinAlgPack::SparseVectorSlice< T_Element >::is_sorted ( ) const
inline

Return true if the sequence is assumed sorted.

Definition at line 1043 of file AbstractLinAlgPack_SparseVectorClassDecl.hpp.

template<class T_Element >
SparseVectorSlice< T_Element >::iterator AbstractLinAlgPack::SparseVectorSlice< T_Element >::begin ( )
inline
template<class T_Element >
SparseVectorSlice< T_Element >::const_iterator AbstractLinAlgPack::SparseVectorSlice< T_Element >::begin ( ) const
inline
template<class T_Element >
SparseVectorSlice< T_Element >::const_iterator AbstractLinAlgPack::SparseVectorSlice< T_Element >::end ( ) const
inline
template<class T_Element >
SparseVectorSlice< T_Element >::reverse_iterator AbstractLinAlgPack::SparseVectorSlice< T_Element >::rbegin ( )
inline
template<class T_Element >
SparseVectorSlice< T_Element >::const_reverse_iterator AbstractLinAlgPack::SparseVectorSlice< T_Element >::rbegin ( ) const
inline
template<class T_Element >
SparseVectorSlice< T_Element >::const_reverse_iterator AbstractLinAlgPack::SparseVectorSlice< T_Element >::rend ( ) const
inline
template<class T_Element >
SparseVectorSlice< T_Element >::element_type * AbstractLinAlgPack::SparseVectorSlice< T_Element >::lookup_element ( size_type  i)
inline
template<class T_Element >
const SparseVectorSlice< T_Element >::element_type * AbstractLinAlgPack::SparseVectorSlice< T_Element >::lookup_element ( size_type  i) const
inline
template<class T_Element >
SparseVectorSlice< T_Element > & AbstractLinAlgPack::SparseVectorSlice< T_Element >::operator() ( )
inline

Returns a SparseVectorSlice<> reference to this object.

It is included for uniformity with SparseVector.

Definition at line 1108 of file AbstractLinAlgPack_SparseVectorClassDecl.hpp.

template<class T_Element >
const SparseVectorSlice< T_Element > & AbstractLinAlgPack::SparseVectorSlice< T_Element >::operator() ( ) const
inline
template<class T_Element>
SparseVectorSlice* AbstractLinAlgPack::SparseVectorSlice< T_Element >::operator& ( )
inline

Allow address to be taken of an rvalue of this object.

Definition at line 723 of file AbstractLinAlgPack_SparseVectorClassDecl.hpp.

template<class T_Element >
SparseVectorSlice< T_Element > AbstractLinAlgPack::SparseVectorSlice< T_Element >::operator() ( const Range1D rng)
inline

Returns a continous subregion of the SparseVector object.

The returned SparseVectorSlice object represents the range of the rng argument.

Preconditions:

  • #rng.ubound() - 1 <= this->dim()# (throw #out_of_range#)
  • dim() > 0# (throw #UnsizedException#)

Postconditions:

  • returned#.dim() == rng.ubound() - rng.lbound() + 1#
  • contains all of the elements in the range.
Parameters
rngIndex range [lbound,ubound] of the region being returned.

Definition at line 1118 of file AbstractLinAlgPack_SparseVectorClassDecl.hpp.

template<class T_Element >
const SparseVectorSlice< T_Element > AbstractLinAlgPack::SparseVectorSlice< T_Element >::operator() ( const Range1D rng) const
inline
template<class T_Element >
SparseVectorSlice< T_Element > AbstractLinAlgPack::SparseVectorSlice< T_Element >::operator() ( size_type  lbound,
size_type  ubound 
)
inline

Returns a SparseVectorSlice object for the continous subregion [ubound, lbound].

Preconditions:

  • #lbound > 1# (throw #out_of_range#)
  • #lbound < ubound# (throw #out_of_range#)
  • #ubound <= this->dim()# (throw #out_of_range#)

Postconditions:

  • returned#.dim() == ubound() - lbound() + 1#
  • contains all of the elements in the range.
Parameters
lboundLower bound of range [lbound,ubound] of the region being returned.
uboundUpper bound of range [lbound,ubound] of the region being returned.

Definition at line 1128 of file AbstractLinAlgPack_SparseVectorClassDecl.hpp.

template<class T_Element >
const SparseVectorSlice< T_Element > AbstractLinAlgPack::SparseVectorSlice< T_Element >::operator() ( size_type  lbound,
size_type  ubound 
) const
inline

The documentation for this class was generated from the following files: