AbstractLinAlgPack::SparseVectorSlice< T_Element > Class Template Reference

Sparse Vector Slice class template. More...

#include <AbstractLinAlgPack_SparseVectorClassDecl.hpp>

Inheritance diagram for AbstractLinAlgPack::SparseVectorSlice< T_Element >:

[legend]
List of all members.

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.

Sparse Vector Templated interface for linear algebra operations

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

Public Member Functions

void bind (SparseVectorSlice svs)
 Constructs a sparse vector slice view from another sparse vector slice.
EOverLap overlap (const SparseVectorSlice< T_Element > &sv) 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 542 of file AbstractLinAlgPack_SparseVectorClassDecl.hpp.


Member Typedef Documentation

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

Definition at line 548 of file AbstractLinAlgPack_SparseVectorClassDecl.hpp.

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

Definition at line 550 of file AbstractLinAlgPack_SparseVectorClassDecl.hpp.

template<class T_Element>
typedef ptrdiff_t AbstractLinAlgPack::SparseVectorSlice< T_Element >::difference_type
 

Definition at line 552 of file AbstractLinAlgPack_SparseVectorClassDecl.hpp.

template<class T_Element>
typedef element_type* AbstractLinAlgPack::SparseVectorSlice< T_Element >::iterator
 

Definition at line 554 of file AbstractLinAlgPack_SparseVectorClassDecl.hpp.

template<class T_Element>
typedef const element_type* AbstractLinAlgPack::SparseVectorSlice< T_Element >::const_iterator
 

Definition at line 556 of file AbstractLinAlgPack_SparseVectorClassDecl.hpp.

template<class T_Element>
typedef std::reverse_iterator<iterator> AbstractLinAlgPack::SparseVectorSlice< T_Element >::reverse_iterator
 

Definition at line 570 of file AbstractLinAlgPack_SparseVectorClassDecl.hpp.

template<class T_Element>
typedef std::reverse_iterator<const_iterator> AbstractLinAlgPack::SparseVectorSlice< T_Element >::const_reverse_iterator
 

Definition at line 572 of file AbstractLinAlgPack_SparseVectorClassDecl.hpp.

template<class T_Element>
typedef SparseVectorUtilityPack::DoesNotExistException AbstractLinAlgPack::SparseVectorSlice< T_Element >::DoesNotExistException
 

Definition at line 577 of file AbstractLinAlgPack_SparseVectorClassDecl.hpp.

template<class T_Element>
typedef SparseVectorUtilityPack::NotSortedException AbstractLinAlgPack::SparseVectorSlice< T_Element >::NotSortedException
 

Definition at line 579 of file AbstractLinAlgPack_SparseVectorClassDecl.hpp.


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:
ele pointer to array of elements (length nz#)
offset offset for the indexes of the elements. index = ele[i].index() + offset
size number of elements in the full vector
nz number of non-zero elements in vector

Definition at line 999 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 1005 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 409 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 1015 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 1020 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 1025 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 1030 of file AbstractLinAlgPack_SparseVectorClassDecl.hpp.

template<class T_Element>
SparseVectorSlice< T_Element >::iterator AbstractLinAlgPack::SparseVectorSlice< T_Element >::begin  )  [inline]
 

Definition at line 1035 of file AbstractLinAlgPack_SparseVectorClassDecl.hpp.

template<class T_Element>
SparseVectorSlice< T_Element >::const_iterator AbstractLinAlgPack::SparseVectorSlice< T_Element >::begin  )  const [inline]
 

Definition at line 1040 of file AbstractLinAlgPack_SparseVectorClassDecl.hpp.

template<class T_Element>
SparseVectorSlice< T_Element >::const_iterator AbstractLinAlgPack::SparseVectorSlice< T_Element >::end  )  const [inline]
 

Definition at line 1050 of file AbstractLinAlgPack_SparseVectorClassDecl.hpp.

template<class T_Element>
SparseVectorSlice< T_Element >::reverse_iterator AbstractLinAlgPack::SparseVectorSlice< T_Element >::rbegin  )  [inline]
 

Definition at line 1055 of file AbstractLinAlgPack_SparseVectorClassDecl.hpp.

template<class T_Element>
SparseVectorSlice< T_Element >::const_reverse_iterator AbstractLinAlgPack::SparseVectorSlice< T_Element >::rbegin  )  const [inline]
 

Definition at line 1060 of file AbstractLinAlgPack_SparseVectorClassDecl.hpp.

template<class T_Element>
SparseVectorSlice< T_Element >::const_reverse_iterator AbstractLinAlgPack::SparseVectorSlice< T_Element >::rend  )  const [inline]
 

Definition at line 1070 of file AbstractLinAlgPack_SparseVectorClassDecl.hpp.

template<class T_Element>
SparseVectorSlice< T_Element >::element_type * AbstractLinAlgPack::SparseVectorSlice< T_Element >::lookup_element size_type  i  )  [inline]
 

Definition at line 1079 of file AbstractLinAlgPack_SparseVectorClassDecl.hpp.

template<class T_Element>
const SparseVectorSlice< T_Element >::element_type * AbstractLinAlgPack::SparseVectorSlice< T_Element >::lookup_element size_type  i  )  const [inline]
 

Definition at line 1087 of file AbstractLinAlgPack_SparseVectorClassDecl.hpp.

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 1095 of file AbstractLinAlgPack_SparseVectorClassDecl.hpp.

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

Definition at line 1100 of file AbstractLinAlgPack_SparseVectorClassDecl.hpp.

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 710 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:
rng Index range [lbound,ubound] of the region being returned.

Definition at line 1105 of file AbstractLinAlgPack_SparseVectorClassDecl.hpp.

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

Definition at line 1110 of file AbstractLinAlgPack_SparseVectorClassDecl.hpp.

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:
lbound Lower bound of range [lbound,ubound] of the region being returned.
ubound Upper bound of range [lbound,ubound] of the region being returned.

Definition at line 1115 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]
 

Definition at line 1120 of file AbstractLinAlgPack_SparseVectorClassDecl.hpp.


The documentation for this class was generated from the following files:
Generated on Thu Sep 18 12:33:54 2008 for AbstractLinAlgPack: C++ Interfaces For Vectors, Matrices And Related Linear Algebra Objects by doxygen 1.3.9.1