#include "keyvalue/value/Single.h"
Public Member Functions | |
Single () | |
Default constructor sets content to Variant's default. | |
Single (const Variant &data) | |
Builds and sets content. | |
template<typename Rhs > | |
Single (const Rhs &rhs) | |
Builds and sets content. | |
template<typename Rhs > | |
Single & | operator= (const Rhs &rhs) |
Assignment operator. | |
size_t | getSize () const |
Gets Vector size. | |
void | resize (size_t size) |
Resizes the vector. | |
void | resize (size_t nRows, size_t nCols) |
Resizes the matrix. | |
const Variant & | operator() (size_t i) const |
Provides access to the i-th element. | |
Variant & | operator() (size_t i) |
Non const operator()(). | |
const Variant & | operator() (size_t i, size_t j) const |
Provides access to the element in the i-th row and j-th column. | |
Variant & | operator() (size_t i, size_t j) |
Non const operator()(). | |
void | transpose () |
Transposes the vector. | |
size_t | getNRows () const |
Gets number of rows. | |
size_t | getNCols () const |
Gets number of columns. | |
bool | operator== (const Matrix &rhs) const |
Comparison operator. | |
Protected Member Functions | |
void | transposeVector () |
Transposes the matrix if one of its dimensions is 1. |
A 1 x 1 Matrix.
See Matrix documentation for more details.
Builds and sets content.
Takes type on the 1-level-down on the value hierarchy.
data | : The content. |
Single | ( | const Rhs & | rhs | ) | [inline] |
Builds and sets content.
Takes type on a 2-or-more-levels-down on the value hierarchy.
rhs | : The content. |
If you get an error here about 'keyvaluevalue::Parent<Rhs>', this means that Rhs isn't in a lower level in the hierarchy.
Single & operator= | ( | const Rhs & | rhs | ) | [inline] |
Assignment operator.
Takes type on a 2-or-more-levels-down on the value hierarchy.
rhs | : The data to be assigned. |
this
. If you get an error here about 'keyvaluevalue::Parent<Rhs>', this means that Rhs isn't in a lower level in the hierarchy.
size_t getSize | ( | ) | const [inherited] |
Gets Vector size.
void resize | ( | size_t | size | ) | [inherited] |
Resizes the vector.
The size of a vector can not increase. Debug build check for this and an exception is thrown when the test fails. Release build has undefined behavior in this case.
size | : New size. |
LogicError | : (Debug build only) If the new dimension is greater than the original one. |
void resize | ( | size_t | nRows, | |
size_t | nCols | |||
) | [inherited] |
Resizes the matrix.
The size of a matrix (i.e., number of rows times number of columns) can not increase. Debug build check for this and an exception is thrown when the test fails. Release build has undefined behavior in this case.
The contents of a matrix after resizing is undefined.
nRows | : number of rows; | |
nCols | : number of columns. |
LogicError | : (Debug build only) If the new size is greater than the original one. |
const Variant& operator() | ( | size_t | i | ) | const [inherited] |
Provides access to the i-th element.
Debug build performs bound check and throws an exception when the check fail. Release build has undefined behavior in that circumstance.
i | : Element's index. |
const
reference to the i-th element.LogicError | : (Debug build only) When i is not smaller than vector's dimension. |
Variant& operator() | ( | size_t | i | ) | [inherited] |
Non const
operator()().
const Variant& operator() | ( | size_t | i, | |
size_t | j | |||
) | const [inherited] |
Provides access to the element in the i-th row and j-th column.
Debug build perform bound checks and throws an exception on failure. Release build has undefined behavior in that case.
i | : Row index; | |
j | : Column index. |
const
reference to (i, j)-th element.LogicError | : (Debug build only) If i is not smaller than the number of rows or j is not smaller than the number of columns. |
Variant& operator() | ( | size_t | i, | |
size_t | j | |||
) | [inherited] |
Non const
operator()().
void transpose | ( | ) | [inherited] |
Transposes the vector.
size_t getNRows | ( | ) | const [inherited] |
Gets number of rows.
size_t getNCols | ( | ) | const [inherited] |
Gets number of columns.
bool operator== | ( | const Matrix & | rhs | ) | const [inherited] |
Comparison operator.
Recall that Matrix has reference semantics. Consider the code:
Matrix m1(2,2);
m1(0,0) = m1(0,1) = m1(1,0) = m1(1,1) = 1.0;
Matrix m2(2,2); m2(0,0) = m2(0,1) = m2(1,0) = m2(1,1) = 1.0;
Matrix m3(m1);
Then m1 == m2
is false
and m1 == m3
is true
.
rhs | : The Value to be compared against. |
true
if *this and rhs refer to the same data. Otherwise it returns false
. void transposeVector | ( | ) | [protected, inherited] |
Transposes the matrix if one of its dimensions is 1.
In-place matrix transposition is a complicated stuff. See
http://en.wikipedia.org/wiki/In-place_matrix_transposition
However, since the storage is linear, the memory layouts of n x 1 and 1 x n matrix, are the same. Hence, we only need to swap dimensions. This method is intent to perform only this simple transposition and it is protected to be called by Vector which derives from this class.
Debug build checks if either of the dimensions is 1 and throws an exception if the test fails. Release build has undefined behaviour in that circumstance.
LogicError | : (Debug build only) If none of dimensions is 1. |