AbstractLinAlgPack::SparseVectorSlice< T_Element > Class Template Reference

Sparse Vector Slice class template. More...

#include <AbstractLinAlgPack_SparseVectorClassDecl.hpp>

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
 
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.
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
 

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

Private Types

typedef SparseVectorUtilityPack::SpVecIndexLookup<
element_type
index_lookup_type
 

Private Member Functions

void assert_is_sorted () const
SparseVectorSlice< T_Element > get_slice (const Range1D &rng) const
 Return a SparseVectorSlice (inplementation for indexing operators).
 SparseVectorSlice ()
 Not defined and not to be called.
SparseVectorSlice< element_type > & operator= (const SparseVectorSlice< element_type > &)
 Not defined and not to be called.

Private Attributes

index_lookup_type index_lookup_
size_type size_
bool assume_sorted_


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.

template<class T_Element>
typedef SparseVectorUtilityPack::SpVecIndexLookup<element_type> AbstractLinAlgPack::SparseVectorSlice< T_Element >::index_lookup_type [private]

Definition at line 767 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:

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.

template<class T_Element>
AbstractLinAlgPack::SparseVectorSlice< T_Element >::SparseVectorSlice (  )  [private]

Not defined and not to be called.


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 >::iterator AbstractLinAlgPack::SparseVectorSlice< T_Element >::end (  )  [inline]

Definition at line 1045 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 >::reverse_iterator AbstractLinAlgPack::SparseVectorSlice< T_Element >::rend (  )  [inline]

Definition at line 1065 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>
const SparseVectorSlice* AbstractLinAlgPack::SparseVectorSlice< T_Element >::operator & (  )  const [inline]

Definition at line 713 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:

Postconditions:

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:

Postconditions:

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.

template<class T_Element>
void AbstractLinAlgPack::SparseVectorSlice< T_Element >::assert_is_sorted (  )  const [inline, private]

Definition at line 781 of file AbstractLinAlgPack_SparseVectorClassDecl.hpp.

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

Return a SparseVectorSlice (inplementation for indexing operators).

Definition at line 786 of file AbstractLinAlgPack_SparseVectorClassDecl.hpp.

template<class T_Element>
SparseVectorSlice<element_type>& AbstractLinAlgPack::SparseVectorSlice< T_Element >::operator= ( const SparseVectorSlice< element_type > &   )  [private]

Not defined and not to be called.


Member Data Documentation

template<class T_Element>
index_lookup_type AbstractLinAlgPack::SparseVectorSlice< T_Element >::index_lookup_ [private]

Definition at line 772 of file AbstractLinAlgPack_SparseVectorClassDecl.hpp.

template<class T_Element>
size_type AbstractLinAlgPack::SparseVectorSlice< T_Element >::size_ [private]

Definition at line 773 of file AbstractLinAlgPack_SparseVectorClassDecl.hpp.

template<class T_Element>
bool AbstractLinAlgPack::SparseVectorSlice< T_Element >::assume_sorted_ [private]

Definition at line 774 of file AbstractLinAlgPack_SparseVectorClassDecl.hpp.


The documentation for this class was generated from the following files:
Generated on Tue Jul 13 09:35:36 2010 for MOOCHO (Single Doxygen Collection) by  doxygen 1.4.7