Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

atlas::bitvector::BitMatrix< dim > Class Template Reference

A matrix of d_rows rows and d_columns columns, with entries in Z/2Z. More...

#include <bitvector.h>

List of all members.

Public Member Functions

 BitMatrix ()
 BitMatrix (size_t n)
 BitMatrix (size_t m, size_t n)
 BitMatrix (const std::vector< BitVector< dim > > &)
 BitMatrix (const latticetypes::LatticeMatrix &m)
 ~BitMatrix ()
 BitMatrix (const BitMatrix &m)
BitMatrixoperator= (const BitMatrix &m)
void apply (BitVector< dim > &, const BitVector< dim > &) const
 Applies the |BitMatrix| to |source| and puts the result in |dest|.
template<typename I, typename O>
void apply (const I &, const I &, O) const
 A pipe-version of apply.
const BitVector< dim > column (size_t j) const
void column (BitVector< dim > &, size_t) const
 Puts in c the j-th column of the matrix.
bool isEmpty () const
BitVectorList< dim > image () const
 Puts in |b| a basis of the image of the matrix.
void kernel (std::vector< BitVector< dim > > &) const
 Puts in |b| a normal basis for the kernel of the matrix (but not the canonical basis of that subspace; it is normal for the lexicographically {maximal} possible set of bit positions).
size_t numColumns () const
size_t numRows () const
void row (BitVector< dim > &, size_t) const
bool test (size_t i, size_t j) const
BitMatrixoperator+= (const BitMatrix &)
 Increment *this by adding m.
BitMatrixoperator *= (const BitMatrix &)
 Right multiply our BitMatrix by |m|.
void addColumn (const bitset::BitSet< dim > &f)
void addColumn (const BitVector< dim > &c)
void addToColumn (size_t j, const BitVector< dim > &v)
BitMatrixinvert ()
 Replaces the current matrix by its inverse.
BitMatrixset (size_t i, size_t j)
BitMatrixreset (size_t i, size_t j)
void set (size_t i, size_t j, bool b)
void set_mod2 (size_t i, size_t j, unsigned long v)
void reset ()
 Resets the matrix to zero.
void resize (size_t n)
void resize (size_t m, size_t n)
 Resizes the matrix to |m| rows, |n| columns, leaving data around.
void setColumn (size_t j, const bitset::BitSet< dim > &data)
void swap (BitMatrix &m)
 Swaps contents with m.
BitMatrixtranspose ()
 Transposes the matrix.

Private Attributes

std::vector< bitset::BitSet<
dim > > 
d_data
size_t d_rows
size_t d_columns


Detailed Description

template<size_t dim>
class atlas::bitvector::BitMatrix< dim >

A matrix of d_rows rows and d_columns columns, with entries in Z/2Z.

The number of rows d_rows should be less than or equal to dim, which in turn is envisioned to be at most four times the machine word size. The present implementation allows dim at most twice the machine word size, and what is used is dim equal to RANK_MAX (now 16).

At least when d_columns is less than or equal to dim, the matrix can act on the left on a BitVector of size d_columns; in this setting each column of the matrix is the image of one of the standard basis vectors in the domain.

What is stored in d_data, as BitSet's, are the d_column column vectors of the matrix. Construction of a matrix is therefore most efficient when columns are added to it.

Notice that the columns are BitSets and not BitVectors. A BitVector is a larger data structure than a BitSet, including also an integer d_size saying how many of the available bits are significant. In a BitMatrix this integer must be the same for all of the columns, so it is easier and safer to store it once for the whole BitMatrix, and also to modify it just once when the matrix is resized.

Definition at line 378 of file bitvector.h.


Constructor & Destructor Documentation

template<size_t dim>
atlas::bitvector::BitMatrix< dim >::BitMatrix  )  [inline]
 

Definition at line 401 of file bitvector.h.

template<size_t dim>
atlas::bitvector::BitMatrix< dim >::BitMatrix size_t  n  )  [inline, explicit]
 

Definition at line 405 of file bitvector.h.

template<size_t dim>
atlas::bitvector::BitMatrix< dim >::BitMatrix size_t  m,
size_t  n
[inline]
 

Definition at line 413 of file bitvector.h.

template<size_t dim>
atlas::bitvector::BitMatrix< dim >::BitMatrix const std::vector< BitVector< dim > > &  b  )  [explicit]
 

Constructs the matrix whose columns are given by the vectors in |b|.

NOTE : it is assumed that all the vectors in |b| have the same size.

Definition at line 129 of file bitvector_def.h.

References atlas::bitvector::BitMatrix< dim >::d_data, and atlas::bitvector::BitMatrix< dim >::d_rows.

template<size_t dim>
atlas::bitvector::BitMatrix< dim >::BitMatrix const latticetypes::LatticeMatrix m  )  [inline, explicit]
 

Definition at line 423 of file bitvector.h.

template<size_t dim>
atlas::bitvector::BitMatrix< dim >::~BitMatrix  )  [inline]
 

Definition at line 435 of file bitvector.h.

template<size_t dim>
atlas::bitvector::BitMatrix< dim >::BitMatrix const BitMatrix< dim > &  m  )  [inline]
 

Definition at line 439 of file bitvector.h.


Member Function Documentation

template<size_t dim>
void atlas::bitvector::BitMatrix< dim >::addColumn const BitVector< dim > &  c  )  [inline]
 

Definition at line 521 of file bitvector.h.

template<size_t dim>
void atlas::bitvector::BitMatrix< dim >::addColumn const bitset::BitSet< dim > &  f  )  [inline]
 

Adds the BitSet f as a new column at the end to the BitMatrix.

Definition at line 516 of file bitvector.h.

Referenced by atlas::subquotient::subquotientMap().

template<size_t dim>
void atlas::bitvector::BitMatrix< dim >::addToColumn size_t  j,
const BitVector< dim > &  v
[inline]
 

Adds the BitVector v to column j of the BitMatrix.

Definition at line 529 of file bitvector.h.

template<size_t dim>
template<typename I, typename O>
void atlas::bitvector::BitMatrix< dim >::apply const I &  first,
const I &  last,
out
const
 

A pipe-version of apply.

We assume that I is an InputIterator with value-type BitVector<dim>, and O an OutputIterator with the same value-type. Then we apply our matrix to each vector in [first,last[ and output it to out.

Definition at line 173 of file bitvector_def.h.

template<size_t dim>
void atlas::bitvector::BitMatrix< dim >::apply BitVector< dim > &  dest,
const BitVector< dim > &  source
const
 

Applies the |BitMatrix| to |source| and puts the result in |dest|.

It is assumed that |d_columns| is equal to |source.size()|. The result size will be set from |d_rows|.

Definition at line 154 of file bitvector_def.h.

References atlas::bitvector::combination(), and atlas::bitvector::BitVector< dim >::data().

Referenced by atlas::subquotient::Subspace< dim >::apply(), atlas::subquotient::subquotientMap(), and atlas::cartanclass::Fiber::toAdjoint().

template<size_t dim>
void atlas::bitvector::BitMatrix< dim >::column BitVector< dim > &  c,
size_t  j
const
 

Puts in c the j-th column of the matrix.

NOTE: we cannot simply return d_data[j] because that would be a BitSet, not a BitVector!

Definition at line 193 of file bitvector_def.h.

template<size_t dim>
const BitVector<dim> atlas::bitvector::BitMatrix< dim >::column size_t  j  )  const [inline]
 

Returns column $j$ of the BitMatrix, as a BitVector.

Definition at line 463 of file bitvector.h.

Referenced by atlas::bitvector::BitMatrix< dim >::image(), and atlas::cartanclass::Fiber::makeStrongRepresentatives().

template<size_t dim>
BitVectorList< dim > atlas::bitvector::BitMatrix< dim >::image  )  const
 

Puts in |b| a basis of the image of the matrix.

Definition at line 229 of file bitvector_def.h.

References atlas::bitvector::BitMatrix< dim >::column(), and atlas::bitvector::spanAdd().

Referenced by atlas::cartanclass::Fiber::makeRealFormPartition().

template<size_t dim>
BitMatrix< dim > & atlas::bitvector::BitMatrix< dim >::invert  ) 
 

Replaces the current matrix by its inverse.

[This code is untested by me, and may be removed if no use is found. MvL]

It is the caller's responsibility to make sure that m is in fact invertible (in particular, that it is square). If necessary, this may be done by a call to isInvertible().

For the algorithm, we use the normalSpanAdd function. We start out with a matrix of size (2r,c) (if r,c is the size of our original matrix) containing the identity matrix below the given one. Then we apply normalSpanAdd; at the end, the upper part of our matrix is (some permutattion of) the identity. Setting it right will finish the job.

Actually, since this would require working with BitMatrix<2*dim>, and since conversion functions don't seem to be forthcoming, we work with a pair of matrices, and just copy the code from normalSpanAdd.

Definition at line 341 of file bitvector_def.h.

References atlas::bitvector::BitMatrix< dim >::d_data, atlas::bitvector::BitMatrix< dim >::d_rows, atlas::bits::firstBit(), atlas::bitvector::BitMatrix< dim >::set(), and atlas::bitvector::BitMatrix< dim >::test().

template<size_t dim>
bool atlas::bitvector::BitMatrix< dim >::isEmpty  )  const [inline]
 

Tests whether the BitMatrix is empty (has zero columns).

Definition at line 473 of file bitvector.h.

template<size_t dim>
void atlas::bitvector::BitMatrix< dim >::kernel std::vector< BitVector< dim > > &  b  )  const
 

Puts in |b| a normal basis for the kernel of the matrix (but not the canonical basis of that subspace; it is normal for the lexicographically {maximal} possible set of bit positions).

This is based on normalizing the transpose matrix, and then solving the resulting trivialised system of equations.

Definition at line 241 of file bitvector_def.h.

References atlas::bitset::BitSet< n >::begin(), atlas::bitvector::normalize(), and atlas::bitvector::BitVector< dim >::set().

Referenced by atlas::topology::Connectivity::Connectivity(), atlas::tori::dualPi0(), atlas::cartanclass::Fiber::gradingGroup(), and atlas::makeTopology().

template<size_t dim>
size_t atlas::bitvector::BitMatrix< dim >::numColumns  )  const [inline]
 

Returns the number of columns of the BitMatrix.

Definition at line 485 of file bitvector.h.

Referenced by atlas::subquotient::Subspace< dim >::apply(), and atlas::subquotient::subquotientMap().

template<size_t dim>
size_t atlas::bitvector::BitMatrix< dim >::numRows  )  const [inline]
 

Returns the number of rows of the BitMatrix.

Definition at line 492 of file bitvector.h.

Referenced by atlas::subquotient::Subspace< dim >::apply(), and atlas::subquotient::subquotientMap().

template<size_t dim>
BitMatrix< dim > & atlas::bitvector::BitMatrix< dim >::operator *= const BitMatrix< dim > &  m  ) 
 

Right multiply our BitMatrix by |m|.

As in apply, this can be done rather efficently by computing a whole column at a time.

NOTE : of course |m.d_rows| must be equal to |d_columns|.

Definition at line 315 of file bitvector_def.h.

References atlas::bitvector::combination(), atlas::bitvector::BitMatrix< dim >::d_columns, atlas::bitvector::BitMatrix< dim >::d_data, atlas::bitvector::BitMatrix< dim >::d_rows, and atlas::bitvector::BitMatrix< dim >::swap().

template<size_t dim>
BitMatrix< dim > & atlas::bitvector::BitMatrix< dim >::operator+= const BitMatrix< dim > &  m  ) 
 

Increment *this by adding m.

Precondition: m has the same size as the current matrix.

Definition at line 297 of file bitvector_def.h.

References atlas::bitvector::BitMatrix< dim >::d_columns, atlas::bitvector::BitMatrix< dim >::d_data, and atlas::bitvector::BitMatrix< dim >::d_rows.

template<size_t dim>
BitMatrix& atlas::bitvector::BitMatrix< dim >::operator= const BitMatrix< dim > &  m  )  [inline]
 

Definition at line 445 of file bitvector.h.

template<size_t dim>
void atlas::bitvector::BitMatrix< dim >::reset  ) 
 

Resets the matrix to zero.

Definition at line 400 of file bitvector_def.h.

References atlas::bitvector::BitMatrix< dim >::d_data, and atlas::bitvector::BitMatrix< dim >::reset().

template<size_t dim>
BitMatrix& atlas::bitvector::BitMatrix< dim >::reset size_t  i,
size_t  j
[inline]
 

Definition at line 546 of file bitvector.h.

Referenced by atlas::bitvector::identityMatrix(), and atlas::bitvector::BitMatrix< dim >::reset().

template<size_t dim>
void atlas::bitvector::BitMatrix< dim >::resize size_t  m,
size_t  n
 

Resizes the matrix to |m| rows, |n| columns, leaving data around.

Definition at line 411 of file bitvector_def.h.

References atlas::bitvector::BitMatrix< dim >::d_columns, atlas::bitvector::BitMatrix< dim >::d_data, atlas::bitvector::BitMatrix< dim >::d_rows, and atlas::bitvector::BitMatrix< dim >::resize().

template<size_t dim>
void atlas::bitvector::BitMatrix< dim >::resize size_t  n  )  [inline]
 

Resizes the BitMatrix to an n by n square.

NOTE: it is the caller's responsibility to check that n does not exceed dim.

Definition at line 570 of file bitvector.h.

Referenced by atlas::bitvector::identityMatrix(), atlas::lattice::mod2(), atlas::bitvector::BitMatrix< dim >::resize(), and atlas::subquotient::subquotientMap().

template<size_t dim>
void atlas::bitvector::BitMatrix< dim >::row BitVector< dim > &  r,
size_t  i
const
 

Puts in r the i-th row of the matrix.

Definition at line 208 of file bitvector_def.h.

References atlas::bitvector::BitVector< dim >::reset(), atlas::bitvector::BitVector< dim >::resize(), atlas::bitvector::BitVector< dim >::set(), and test().

template<size_t dim>
void atlas::bitvector::BitMatrix< dim >::set size_t  i,
size_t  j,
bool  b
[inline]
 

Definition at line 553 of file bitvector.h.

template<size_t dim>
BitMatrix& atlas::bitvector::BitMatrix< dim >::set size_t  i,
size_t  j
[inline]
 

Puts a 1 in row i and column j of the BitMatrix.

Definition at line 539 of file bitvector.h.

Referenced by atlas::bitvector::identityMatrix(), atlas::bitvector::initBasis(), atlas::bitvector::BitMatrix< dim >::invert(), and atlas::bitvector::BitMatrix< dim >::transpose().

template<size_t dim>
void atlas::bitvector::BitMatrix< dim >::set_mod2 size_t  i,
size_t  j,
unsigned long  v
[inline]
 

Definition at line 557 of file bitvector.h.

Referenced by atlas::cartanclass::Fiber::makeBaseGrading(), and atlas::lattice::mod2().

template<size_t dim>
void atlas::bitvector::BitMatrix< dim >::setColumn size_t  j,
const bitset::BitSet< dim > &  data
[inline]
 

Puts the BitSet data in column j of the BitMatrix.

Definition at line 579 of file bitvector.h.

template<size_t dim>
void atlas::bitvector::BitMatrix< dim >::swap BitMatrix< dim > &  m  ) 
 

Swaps contents with m.

Definition at line 425 of file bitvector_def.h.

References atlas::bitvector::BitMatrix< dim >::d_columns, atlas::bitvector::BitMatrix< dim >::d_data, and atlas::bitvector::BitMatrix< dim >::d_rows.

Referenced by atlas::bitvector::BitMatrix< dim >::operator *=(), atlas::subquotient::Subspace< dim >::swap(), atlas::cartanclass::Fiber::swap(), and atlas::bitvector::BitMatrix< dim >::transpose().

template<size_t dim>
bool atlas::bitvector::BitMatrix< dim >::test size_t  i,
size_t  j
const [inline]
 

Tests the (i,j) entry of the BitMatrix.

Definition at line 501 of file bitvector.h.

Referenced by atlas::bitvector::BitMatrix< dim >::invert(), atlas::bitvector::BitMatrix< constants::RANK_MAX >::test(), and atlas::bitvector::BitMatrix< dim >::transpose().

template<size_t dim>
BitMatrix< dim > & atlas::bitvector::BitMatrix< dim >::transpose  ) 
 

Transposes the matrix.

Transposes the BitMatrix

NOTE: it is the caller's responsibility to check that d_columns does not exceed dim.

Definition at line 436 of file bitvector_def.h.

References atlas::bitvector::BitMatrix< dim >::d_columns, atlas::bitvector::BitMatrix< dim >::d_rows, atlas::bitvector::BitMatrix< dim >::set(), atlas::bitvector::BitMatrix< dim >::swap(), and atlas::bitvector::BitMatrix< dim >::test().


Member Data Documentation

template<size_t dim>
size_t atlas::bitvector::BitMatrix< dim >::d_columns [private]
 

Number of columns of the BitMatrix. This field is redundant, see d_data.

Definition at line 396 of file bitvector.h.

Referenced by atlas::bitvector::BitMatrix< dim >::operator *=(), atlas::bitvector::BitMatrix< dim >::operator+=(), atlas::bitvector::BitMatrix< constants::RANK_MAX >::operator=(), atlas::bitvector::BitMatrix< dim >::resize(), atlas::bitvector::BitMatrix< dim >::swap(), and atlas::bitvector::BitMatrix< dim >::transpose().

template<size_t dim>
std::vector<bitset::BitSet<dim> > atlas::bitvector::BitMatrix< dim >::d_data [private]
 

A vector of d_columns BitSet's (each of size d_rows), the columns of the BitMatrix. Thus d_data.size()==d_columns at all times.

Definition at line 386 of file bitvector.h.

Referenced by atlas::bitvector::BitMatrix< dim >::BitMatrix(), atlas::bitvector::BitMatrix< dim >::invert(), atlas::bitvector::BitMatrix< dim >::operator *=(), atlas::bitvector::BitMatrix< dim >::operator+=(), atlas::bitvector::BitMatrix< constants::RANK_MAX >::operator=(), atlas::bitvector::BitMatrix< dim >::reset(), atlas::bitvector::BitMatrix< dim >::resize(), and atlas::bitvector::BitMatrix< dim >::swap().

template<size_t dim>
size_t atlas::bitvector::BitMatrix< dim >::d_rows [private]
 

Number of rows of the BitMatrix. Cannot exceed template argument dim

Definition at line 391 of file bitvector.h.

Referenced by atlas::bitvector::BitMatrix< dim >::BitMatrix(), atlas::bitvector::BitMatrix< dim >::invert(), atlas::bitvector::BitMatrix< dim >::operator *=(), atlas::bitvector::BitMatrix< dim >::operator+=(), atlas::bitvector::BitMatrix< constants::RANK_MAX >::operator=(), atlas::bitvector::BitMatrix< dim >::resize(), atlas::bitvector::BitMatrix< dim >::swap(), and atlas::bitvector::BitMatrix< dim >::transpose().


The documentation for this class was generated from the following files:
Generated on Wed Mar 26 16:52:20 2008 for atlas by  doxygen 1.3.9.1