My Project
|
Class MinorKey can be used for representing keys in a cache for sub-determinantes; see class Cache. More...
#include <Minor.h>
Public Member Functions | |
MinorKey (const int lengthOfRowArray=0, const unsigned int *const rowKey=NULL, const int lengthOfColumnArray=0, const unsigned int *const columnKey=NULL) | |
A constructor for class MinorKey. More... | |
void | set (const int lengthOfRowArray, const unsigned int *rowKey, const int lengthOfColumnArray, const unsigned int *columnKey) |
A setter method for class MinorKey. More... | |
MinorKey (const MinorKey &mk) | |
A copy constructor. More... | |
~MinorKey () | |
A destructor for deleting an instance. More... | |
MinorKey & | operator= (const MinorKey &) |
just to make the compiler happy More... | |
bool | operator== (const MinorKey &) const |
just to make the compiler happy More... | |
bool | operator< (const MinorKey &) const |
just to make the compiler happy More... | |
int | getAbsoluteRowIndex (const int i) const |
A method for retrieving the (0-based) index of the i-th row in the set of rows encoded in this. More... | |
int | getAbsoluteColumnIndex (const int i) const |
A method for retrieving the (0-based) index of the i-th column in the set of columns encoded in this. More... | |
int | getRelativeRowIndex (const int i) const |
A method for retrieving the (0-based) relative index of the i-th row in this MinorKey. More... | |
int | getRelativeColumnIndex (const int i) const |
A method for retrieving the (0-based) relative index of the i-th column in this MinorKey. More... | |
void | getAbsoluteRowIndices (int *const target) const |
A method for retrieving the 0-based indices of all rows encoded in this MinorKey. More... | |
void | getAbsoluteColumnIndices (int *const target) const |
A method for retrieving the 0-based indices of all columns encoded in this MinorKey. More... | |
MinorKey | getSubMinorKey (const int absoluteEraseRowIndex, const int absoluteEraseColumnIndex) const |
A method for retrieving a sub-MinorKey resulting from omitting one row and one column of this MinorKey. More... | |
int | compare (const MinorKey &mk) const |
A comparator for two instances of MinorKey. More... | |
void | selectFirstRows (const int k, const MinorKey &mk) |
This method redefines the set of rows represented by this MinorKey. More... | |
bool | selectNextRows (const int k, const MinorKey &mk) |
This method redefines the set of rows represented by this MinorKey. More... | |
void | selectFirstColumns (const int k, const MinorKey &mk) |
This method redefines the set of columns represented by this MinorKey. More... | |
bool | selectNextColumns (const int k, const MinorKey &mk) |
This method redefines the set of columns represented by this MinorKey. More... | |
std::string | toString () const |
A method for providing a printable version of the represented MinorKey. More... | |
Private Member Functions | |
unsigned int | getRowKey (const int blockIndex) const |
Inlined accessor of blockIndex-th element of _rowKey. More... | |
unsigned int | getColumnKey (const int blockIndex) const |
Accessor of blockIndex-th element of _columnKey. More... | |
void | setRowKey (const int blockIndex, const unsigned int rowKey) |
A method for setting the blockIndex-th element of _rowKey. More... | |
void | setColumnKey (const int blockIndex, const unsigned int columnKey) |
A method for setting the blockIndex-th element of _columnKey. More... | |
int | getNumberOfRowBlocks () const |
Accessor of _numberOfRowBlocks. More... | |
int | getNumberOfColumnBlocks () const |
Accessor of _numberOfColumnBlocks. More... | |
void | reset () |
A method for deleting all entries of _rowKey and _columnKey. More... | |
Private Attributes | |
unsigned int * | _rowKey |
a pointer to an array[0..k-1] of ints, capturing k*32 bits for determining which rows of a pre-defined matrix shall belong to the minor of interest; for i < j, _rowKey[i] holds lower bits than _rowKey[j] More... | |
unsigned int * | _columnKey |
a pointer to an array[0..k-1] of ints, capturing k*32 bits for determining which columns of a pre-defined matrix shall belong to the minor of interest; for i < j, _columnKey[i] holds lower bits than _columnKey[j] More... | |
int | _numberOfRowBlocks |
the number of ints (i.e. More... | |
int | _numberOfColumnBlocks |
the number of ints (i.e. More... | |
Friends | |
class | MinorProcessor |
For letting MinorProcessor see the private methods of this class. More... | |
Class MinorKey can be used for representing keys in a cache for sub-determinantes; see class Cache.
As such, it is a realization of the template class KeyClass which is used in the declaration of class Cache. Following the documentation of class Cache, we need to implement at least the methods:
bool MinorKey::operator< (const MinorKey& key),
bool MinorKey::operator== (const MinorKey& key),
MinorKey uses two private arrays of ints _rowKey
and _columnKey
to encode rows and columns of a pre-defined matrix. Semantically, the row indices and column indices form the key for caching the value of the corresponding minor.
More concretely, let us assume that the pre-defined matrix has 32*R+r, r<32, rows and 32*C+c, c<32, columns. All row indices can then be captured using R+1 ints, since an int is a 32-bit-number (regardless of the platform). The analog holds for the columns. Consequently, each instance of MinorKey encodes the sets of rows and columns which shall belong to the minor of interest (and which shall not).
Example: The _rowKey
with _rowKey
[1] = 0...011 and _rowKey
[0] = 0...01101 encodes the rows with indices 33, 32, 3, 2, and 0.
MinorKey::MinorKey | ( | const int | lengthOfRowArray = 0 , |
const unsigned int *const | rowKey = NULL , |
||
const int | lengthOfColumnArray = 0 , |
||
const unsigned int *const | columnKey = NULL |
||
) |
A constructor for class MinorKey.
The ints given in the array rowKey encode all rows which shall belong to the minor. Each array entry encodes 32 rows, e.g. the i-th array entry 0...01101 encodes the rows with absolute matrix row indices 3+i*32, 2+i*32, and 0+i*32. Analog for columns.
lengthOfRowArray | the length of the array rowKey |
rowKey | a pointer to an array of ints encoding the set of rows of the minor |
lengthOfColumnArray | the length of the array columnKey |
columnKey | a pointer to an array of ints encoding the set of
|
Definition at line 84 of file Minor.cc.
A copy constructor.
This method overrides the shallow copy constructor by a self-written deep copy version.
mk | the MinorKey to be deep copied |
Definition at line 23 of file Minor.cc.
MinorKey::~MinorKey | ( | ) |
A destructor for deleting an instance.
A comparator for two instances of MinorKey.
The ordering induced by this implementation determines the ordering of all (key --> value) pairs in a cache that uses MinorKey as KeyClass.
mk | a second MinorKey to be compared with this instance |
Definition at line 412 of file Minor.cc.
int MinorKey::getAbsoluteColumnIndex | ( | const int | i | ) | const |
A method for retrieving the (0-based) index of the i-th column in the set of columns encoded in this.
Lower values for i
result in lower absolute column indices.
i
columns encoded in the given MinorKey. i | the relative index of the column, as encoded in this |
Definition at line 149 of file Minor.cc.
void MinorKey::getAbsoluteColumnIndices | ( | int *const | target | ) | const |
A method for retrieving the 0-based indices of all columns encoded in this MinorKey.
The user of this method needs to know the number of columns in this, in order to know which indices in target
[k] will be valid.
0...01101
will give rise to the settings target[0] = 0, target[1] = 2, target[2] = 3
, and the user needs to know in advance that there are three columns in this MinorKey. target | a pointer to some array of ints that is to be filled with the requested indices |
Definition at line 202 of file Minor.cc.
int MinorKey::getAbsoluteRowIndex | ( | const int | i | ) | const |
A method for retrieving the (0-based) index of the i-th row in the set of rows encoded in this.
Lower values for i
result in lower absolute row indices.
i
rows encoded in the given MinorKey. i | the relative index of the row, as encoded in this |
Definition at line 117 of file Minor.cc.
void MinorKey::getAbsoluteRowIndices | ( | int *const | target | ) | const |
A method for retrieving the 0-based indices of all rows encoded in this MinorKey.
The user of this method needs to know the number of rows in this, in order to know which indices in target
[k] will be valid.
0...01101
will give rise to the settings target[0] = 0, target[1] = 2, target[2] = 3
, and the user needs to know in advance that there are three rows in this MinorKey. target | a pointer to some array of ints that is to be filled with the requested indices |
Definition at line 181 of file Minor.cc.
|
private |
Accessor of blockIndex-th element of _columnKey.
blockIndex | the index of the int to be retrieved |
|
private |
Accessor of _numberOfColumnBlocks.
|
private |
Accessor of _numberOfRowBlocks.
int MinorKey::getRelativeColumnIndex | ( | const int | i | ) | const |
A method for retrieving the (0-based) relative index of the i-th column in this MinorKey.
Lower values for i
result in lower relative column indices. Note that the absolute index i
is 0-based, too.
i | the absolute 0-based index of a column encoded in this |
i
Definition at line 255 of file Minor.cc.
int MinorKey::getRelativeRowIndex | ( | const int | i | ) | const |
A method for retrieving the (0-based) relative index of the i-th row in this MinorKey.
Lower values for i
result in lower relative row indices. Note that the absolute index i
is 0-based, too.
i | the absolute 0-based index of a row encoded in this |
i
Definition at line 223 of file Minor.cc.
|
private |
MinorKey MinorKey::getSubMinorKey | ( | const int | absoluteEraseRowIndex, |
const int | absoluteEraseColumnIndex | ||
) | const |
A method for retrieving a sub-MinorKey resulting from omitting one row and one column of this MinorKey.
absoluteEraseRowIndex
(counted from lower bits to higher bits) and the column with absolute index absoluteEraseColumnIndex
are actually set in mk
. absoluteEraseRowIndex | the 0-based absolute index of a row in mk |
absoluteEraseColumnIndex | the 0-based absolute index of a column in mk |
Definition at line 343 of file Minor.cc.
just to make the compiler happy
Definition at line 451 of file Minor.cc.
just to make the compiler happy
Definition at line 39 of file Minor.cc.
|
private |
A method for deleting all entries of _rowKey and _columnKey.
This method redefines the set of columns represented by this MinorKey.
After the method, the defined set of columns coincides with the lowest k
columns of mk
. (Here, lowest means w.r.t. indices.)
Note that the method modifies the given instance of MinorKey.
mk
represents at least k
columns. k | the number of columns |
mk | the MinorKey from which to choose the lowest k columns |
Definition at line 498 of file Minor.cc.
This method redefines the set of rows represented by this MinorKey.
After the method, the defined set of rows coincides with the lowest k
rows of mk
. (Here, lowest means w.r.t. indices.)
Note that the method modifies the given instance of MinorKey.
mk
represents at least k
rows. k | the number of rows |
mk | the MinorKey from which to choose the lowest k rows |
Definition at line 457 of file Minor.cc.
This method redefines the set of columns represented by this MinorKey.
Both the old and the new set of k
columns are subsets of the columns represented by mk
. After the method, the defined set of columns is the next sensible choice of k
columns of mk
. (Here, next means the next w.r.t. the increasing index ordering on multi-indices of natural numbers.)
Note that the method modifies the given instance of MinorKey.
mk
represents at least k
columns. Furthermore, the method assumes that the old set of columns represented by this is also a subset of the columns given by mk
. k | the number of columns |
mk | the MinorKey from which to choose the lowest k columns |
k
columns Definition at line 669 of file Minor.cc.
This method redefines the set of rows represented by this MinorKey.
Both the old and the new set of k
rows are subsets of the rows represented by mk
. After the method, the defined set of rows is the next sensible choice of k
rows of mk
. (Here, next means the next w.r.t. the increasing index ordering on multi-indices of natural numbers.)
Note that the method modifies the given instance of MinorKey.
mk
represents at least k
rows. Furthermore, the method assumes that the old set of rows represented by this is also a subset of the rows given by mk
. k | the number of rows |
mk | the MinorKey from which to choose the lowest k rows |
k
rows Definition at line 538 of file Minor.cc.
void MinorKey::set | ( | const int | lengthOfRowArray, |
const unsigned int * | rowKey, | ||
const int | lengthOfColumnArray, | ||
const unsigned int * | columnKey | ||
) |
A setter method for class MinorKey.
Just like the constructor of this class, this method will set all private fields according to the given parameters. Note that this method will change the given instance of MinorKey.
lengthOfRowArray | the length of the array rowKey |
rowKey | a pointer to an array of ints encoding the set of rows of the minor |
lengthOfColumnArray | the length of the array columnKey |
columnKey | a pointer to an array of ints encoding the set of columns of the minor |
Definition at line 62 of file Minor.cc.
A method for setting the blockIndex-th element of _columnKey.
blockIndex | the index of the int to be retrieved |
columnKey | the column key to be set |
string MinorKey::toString | ( | ) | const |
|
friend |
For letting MinorProcessor see the private methods of this class.
|
private |
|
private |
|
private |
|
private |