mcb::spvecfp Class Reference

#include <spvecfp.h>

List of all members.


Detailed Description

A sparse vector with elements in $F_p$.

This class implements a sparse vector with elements in $F_p$. The supported operations are limited to those required by the cycle basis algorithms.

The internal representation is a list of tuples, one for each non-zero entry of the sparse vector. Each tuple contains two integers, the index of the non-zero entry and its value. This entries are supposed to be sorted in order for the various binary operators to work properly. The function append does not ensure this, it is up to the user to make sure that the correct order is maintained.

Remarks:
Indices are between $0$ and $len-1$ where $len$ is the length of the vector.
Date:
2005
Author:
Dimitris Michail


Public Member Functions

 spvecfp ()
 spvecfp (const ptype &p)
 spvecfp (const spvecfp &a)
 ~spvecfp ()
void reset (const ptype &p)
spvecfp operator- () const
ptype operator * (const spvecfp &a) const
spvecfp operator+ (const spvecfp &a) const
spvecfp operator * (const ptype &a)
spvecfpoperator+= (const spvecfp &a)
spvecfpoperator-= (const spvecfp &a)
void print (std::ostream &o) const
void append (indextype index, const ptype &value)
void sort ()
bool empty () const
void clear ()
indextype size () const
ptype pvalue () const
list_item first () const
list_item last () const
list_item succ (list_item it) const
list_item pred (list_item it) const
indextype index (list_item it) const
ptype inf (list_item it) const


Constructor & Destructor Documentation

mcb::spvecfp::spvecfp  ) 
 

Default Constructor

mcb::spvecfp::spvecfp const ptype p  ) 
 

Constructor

Parameters:
p Prime number.

mcb::spvecfp::spvecfp const spvecfp a  ) 
 

Copy constructor

mcb::spvecfp::~spvecfp  ) 
 

Descructor


Member Function Documentation

void mcb::spvecfp::append indextype  index,
const ptype value
 

Append an entry to the sparse vector. The internal representation is a list of sorted entries by index. This procedure does not enforce this order, it simply appends the new entry. Use wisely.

Parameters:
index Index of the new element to append.
value The value of the new element to append.
Remarks:
No attempt to preserve correct sorted order is done. All elements in the vector must have index values less that the new element's for the resulting sparse vector to be valid.

void mcb::spvecfp::clear  ) 
 

Make all elements zero.

bool mcb::spvecfp::empty  )  const
 

Check if the vector is empty, all elements are zero.

Returns:
True if empty, false otherwise.

list_item mcb::spvecfp::first  )  const
 

Get the first item of the internal representation of the vector.

Returns:
The first item of the internal representation.

indextype mcb::spvecfp::index list_item  it  )  const
 

Get the index of an item.

Returns:
The index of an item.

ptype mcb::spvecfp::inf list_item  it  )  const
 

Get the information of an item.

Returns:
The information of an item.

list_item mcb::spvecfp::last  )  const
 

Get the last item of the internal representation of the vector.

Returns:
The last item of the internal representation.

spvecfp mcb::spvecfp::operator * const ptype a  ) 
 

Compute the product with a constant.

Parameters:
a A constant.
Returns:
The product of the current vector with a constant.

ptype mcb::spvecfp::operator * const spvecfp a  )  const
 

Compute the inner product of two vectors.

Parameters:
a A sparse vector.
Returns:
The inner product of this vector and a.

spvecfp mcb::spvecfp::operator+ const spvecfp a  )  const
 

Add two vectors.

Parameters:
a A sparse vector.
Returns:
The sum of this vector and a.

spvecfp& mcb::spvecfp::operator+= const spvecfp a  ) 
 

Add a vector to the current vector.

Parameters:
a A sparse vector a.
Returns:
The current vector after adding a.

spvecfp mcb::spvecfp::operator-  )  const
 

Negate the current sparse vector.

Returns:
A new vector corresponding to current vector negated.

spvecfp& mcb::spvecfp::operator-= const spvecfp a  ) 
 

Subtract a vector from the current vector.

Parameters:
a A sparse vector a.
Returns:
The current vector after subtracting a.

list_item mcb::spvecfp::pred list_item  it  )  const
 

Get the predecessor of an item of the interal representation.

Parameters:
it An item.
Returns:
The predecessor of it.

void mcb::spvecfp::print std::ostream &  o  )  const
 

Print the vector to a stream.

Parameters:
o The stream to print at.

ptype mcb::spvecfp::pvalue  )  const
 

Get the value of the prime p.

Returns:
The value of the prime p.

void mcb::spvecfp::reset const ptype p  ) 
 

Clear the vector and reinitialize it.

Parameters:
p Prime number.

indextype mcb::spvecfp::size  )  const
 

Get the number of non-zero entries.

Returns:
The number of non-zero entries in the vector.

void mcb::spvecfp::sort  ) 
 

Sort the internal representation of the sparse vector. This operation ensures a correct representation after its call. Should not be necessary unless append was called in wrong order.

list_item mcb::spvecfp::succ list_item  it  )  const
 

Get the successor of an item of the internal representation.

Parameters:
it An item.
Returns:
The successor of it.


Generated on Tue Apr 22 13:40:09 2008 for mcb LEDA Extension Package by  doxygen 1.4.6