The Template Sparse Matrix class derived from cv::SparseMat. More...
#include <core.hpp>
Inherits cv::SparseMat.
Public Types | |
typedef SparseMatIterator_< _Tp > | iterator |
typedef SparseMatConstIterator_< _Tp > | const_iterator |
enum | { MAGIC_VAL = 0x42FD0000, MAX_DIM = CV_MAX_DIM, HASH_SCALE = 0x5bd1e995, HASH_BIT = 0x80000000 } |
Public Member Functions | |
SparseMat_ () | |
the default constructor | |
SparseMat_ (int dims, const int *_sizes) | |
the full constructor equivelent to SparseMat(dims, _sizes, DataType<_Tp>::type) | |
SparseMat_ (const SparseMat &m) | |
the copy constructor. If DataType<_Tp>.type != m.type(), the m elements are converted | |
SparseMat_ (const SparseMat_ &m) | |
the copy constructor. This is O(1) operation - no data is copied | |
SparseMat_ (const Mat &m) | |
converts dense matrix to the sparse form | |
SparseMat_ (const CvSparseMat *m) | |
converts the old-style sparse matrix to the C++ class. All the elements are copied | |
SparseMat_ & | operator= (const SparseMat &m) |
the assignment operator. If DataType<_Tp>.type != m.type(), the m elements are converted | |
SparseMat_ & | operator= (const SparseMat_ &m) |
the assignment operator. This is O(1) operation - no data is copied | |
SparseMat_ & | operator= (const Mat &m) |
converts dense matrix to the sparse form | |
SparseMat_ | clone () const |
makes full copy of the matrix. All the elements are duplicated | |
void | create (int dims, const int *_sizes) |
equivalent to cv::SparseMat::create(dims, _sizes, DataType<_Tp>::type) | |
operator CvSparseMat * () const | |
converts sparse matrix to the old-style CvSparseMat. All the elements are copied | |
int | type () const |
returns type of the matrix elements | |
int | depth () const |
returns depth of the matrix elements | |
int | channels () const |
returns the number of channels in each matrix element | |
_Tp & | ref (int i0, size_t *hashval=0) |
equivalent to SparseMat::ref<_Tp>(i0, hashval) | |
_Tp & | ref (int i0, int i1, size_t *hashval=0) |
equivalent to SparseMat::ref<_Tp>(i0, i1, hashval) | |
_Tp & | ref (int i0, int i1, int i2, size_t *hashval=0) |
equivalent to SparseMat::ref<_Tp>(i0, i1, i2, hashval) | |
_Tp & | ref (const int *idx, size_t *hashval=0) |
equivalent to SparseMat::ref<_Tp>(idx, hashval) | |
_Tp | operator() (int i0, size_t *hashval=0) const |
equivalent to SparseMat::value<_Tp>(i0, hashval) | |
_Tp | operator() (int i0, int i1, size_t *hashval=0) const |
equivalent to SparseMat::value<_Tp>(i0, i1, hashval) | |
_Tp | operator() (int i0, int i1, int i2, size_t *hashval=0) const |
equivalent to SparseMat::value<_Tp>(i0, i1, i2, hashval) | |
_Tp | operator() (const int *idx, size_t *hashval=0) const |
equivalent to SparseMat::value<_Tp>(idx, hashval) | |
SparseMatIterator_< _Tp > | begin () |
returns sparse matrix iterator pointing to the first sparse matrix element | |
SparseMatConstIterator_< _Tp > | begin () const |
returns read-only sparse matrix iterator pointing to the first sparse matrix element | |
SparseMatIterator_< _Tp > | end () |
returns sparse matrix iterator pointing to the element following the last sparse matrix element | |
SparseMatConstIterator_< _Tp > | end () const |
returns read-only sparse matrix iterator pointing to the element following the last sparse matrix element | |
void | copyTo (SparseMat &m) const |
copies all the data to the destination matrix. All the previous content of m is erased | |
void | copyTo (Mat &m) const |
converts sparse matrix to dense matrix. | |
void | convertTo (SparseMat &m, int rtype, double alpha=1) const |
multiplies all the matrix elements by the specified scale factor alpha and converts the results to the specified data type | |
void | convertTo (Mat &m, int rtype, double alpha=1, double beta=0) const |
converts sparse matrix to dense n-dim matrix with optional type conversion and scaling. | |
void | assignTo (SparseMat &m, int type=-1) const |
void | create (int dims, const int *_sizes, int _type) |
reallocates sparse matrix. | |
void | clear () |
sets all the sparse matrix elements to 0, which means clearing the hash table. | |
void | addref () |
manually increments the reference counter to the header. | |
void | release () |
size_t | elemSize () const |
returns the size of each element in bytes (not including the overhead - the space occupied by SparseMat::Node elements) | |
size_t | elemSize1 () const |
returns elemSize()/channels() | |
const int * | size () const |
returns the array of sizes, or NULL if the matrix is not allocated | |
int | size (int i) const |
returns the size of i-th matrix dimension (or 0) | |
int | dims () const |
returns the matrix dimensionality | |
size_t | nzcount () const |
returns the number of non-zero elements (=the number of hash table nodes) | |
size_t | hash (int i0) const |
computes the element hash value (1D case) | |
size_t | hash (int i0, int i1) const |
computes the element hash value (2D case) | |
size_t | hash (int i0, int i1, int i2) const |
computes the element hash value (3D case) | |
size_t | hash (const int *idx) const |
computes the element hash value (nD case) | |
template<typename _Tp > | |
_Tp & | value (Node *n) |
returns the value stored in the sparse martix node | |
template<typename _Tp > | |
const _Tp & | value (const Node *n) const |
returns the value stored in the sparse martix node | |
Node * | node (size_t nidx) |
const Node * | node (size_t nidx) const |
uchar * | newNode (const int *idx, size_t hashval) |
void | removeNode (size_t hidx, size_t nidx, size_t previdx) |
void | resizeHashTab (size_t newsize) |
uchar * | ptr (int i0, bool createMissing, size_t *hashval=0) |
specialized variants for 1D, 2D, 3D cases and the generic_type one for n-D case. | |
uchar * | ptr (int i0, int i1, bool createMissing, size_t *hashval=0) |
returns pointer to the specified element (2D case) | |
uchar * | ptr (int i0, int i1, int i2, bool createMissing, size_t *hashval=0) |
returns pointer to the specified element (3D case) | |
uchar * | ptr (const int *idx, bool createMissing, size_t *hashval=0) |
returns pointer to the specified element (nD case) | |
template<typename _Tp > | |
_Tp | value (int i0, size_t *hashval=0) const |
return value of the specified sparse matrix element. | |
template<typename _Tp > | |
_Tp | value (int i0, int i1, size_t *hashval=0) const |
returns value of the specified element (2D case) | |
template<typename _Tp > | |
_Tp | value (int i0, int i1, int i2, size_t *hashval=0) const |
returns value of the specified element (3D case) | |
template<typename _Tp > | |
_Tp | value (const int *idx, size_t *hashval=0) const |
returns value of the specified element (nD case) | |
template<typename _Tp > | |
const _Tp * | find (int i0, size_t *hashval=0) const |
Return pointer to the specified sparse matrix element if it exists. | |
template<typename _Tp > | |
const _Tp * | find (int i0, int i1, size_t *hashval=0) const |
returns pointer to the specified element (2D case) | |
template<typename _Tp > | |
const _Tp * | find (int i0, int i1, int i2, size_t *hashval=0) const |
returns pointer to the specified element (3D case) | |
template<typename _Tp > | |
const _Tp * | find (const int *idx, size_t *hashval=0) const |
returns pointer to the specified element (nD case) | |
void | erase (int i0, int i1, size_t *hashval=0) |
erases the specified element (2D case) | |
void | erase (int i0, int i1, int i2, size_t *hashval=0) |
erases the specified element (3D case) | |
void | erase (const int *idx, size_t *hashval=0) |
erases the specified element (nD case) | |
Public Attributes | |
int | flags |
Hdr * | hdr |
The Template Sparse Matrix class derived from cv::SparseMat.
The class provides slightly more convenient operations for accessing elements.
SparseMat m; ... SparseMat_<int> m_ = (SparseMat_<int>&)m; m_.ref(1)++; // equivalent to m.ref<int>(1)++; m_.ref(2) += m_(3); // equivalent to m.ref<int>(2) += m.value<int>(3);
typedef SparseMatIterator_<_Tp> cv::SparseMat_< _Tp >::iterator |
Reimplemented from cv::SparseMat.
typedef SparseMatConstIterator_<_Tp> cv::SparseMat_< _Tp >::const_iterator |
Reimplemented from cv::SparseMat.
cv::SparseMat_< _Tp >::SparseMat_ | ( | ) |
the default constructor
cv::SparseMat_< _Tp >::SparseMat_ | ( | int | dims, |
const int * | _sizes | ||
) |
the full constructor equivelent to SparseMat(dims, _sizes, DataType<_Tp>::type)
cv::SparseMat_< _Tp >::SparseMat_ | ( | const SparseMat & | m | ) |
the copy constructor. If DataType<_Tp>.type != m.type(), the m elements are converted
cv::SparseMat_< _Tp >::SparseMat_ | ( | const SparseMat_< _Tp > & | m | ) |
the copy constructor. This is O(1) operation - no data is copied
cv::SparseMat_< _Tp >::SparseMat_ | ( | const Mat & | m | ) |
converts dense matrix to the sparse form
cv::SparseMat_< _Tp >::SparseMat_ | ( | const CvSparseMat * | m | ) |
converts the old-style sparse matrix to the C++ class. All the elements are copied
SparseMat_< _Tp > & cv::SparseMat_< _Tp >::operator= | ( | const SparseMat & | m | ) |
the assignment operator. If DataType<_Tp>.type != m.type(), the m elements are converted
Reimplemented from cv::SparseMat.
SparseMat_< _Tp > & cv::SparseMat_< _Tp >::operator= | ( | const SparseMat_< _Tp > & | m | ) |
the assignment operator. This is O(1) operation - no data is copied
SparseMat_< _Tp > & cv::SparseMat_< _Tp >::operator= | ( | const Mat & | m | ) |
converts dense matrix to the sparse form
Reimplemented from cv::SparseMat.
SparseMat_< _Tp > cv::SparseMat_< _Tp >::clone | ( | ) | const |
makes full copy of the matrix. All the elements are duplicated
Reimplemented from cv::SparseMat.
void cv::SparseMat_< _Tp >::create | ( | int | dims, |
const int * | _sizes | ||
) |
equivalent to cv::SparseMat::create(dims, _sizes, DataType<_Tp>::type)
cv::SparseMat_< _Tp >::operator CvSparseMat * | ( | ) | const |
converts sparse matrix to the old-style CvSparseMat. All the elements are copied
Reimplemented from cv::SparseMat.
int cv::SparseMat_< _Tp >::type | ( | ) | const |
returns type of the matrix elements
Reimplemented from cv::SparseMat.
int cv::SparseMat_< _Tp >::depth | ( | ) | const |
returns depth of the matrix elements
Reimplemented from cv::SparseMat.
int cv::SparseMat_< _Tp >::channels | ( | ) | const |
returns the number of channels in each matrix element
Reimplemented from cv::SparseMat.
_Tp & cv::SparseMat_< _Tp >::ref | ( | int | i0, |
size_t * | hashval = 0 |
||
) |
equivalent to SparseMat::ref<_Tp>(i0, hashval)
Reimplemented from cv::SparseMat.
_Tp & cv::SparseMat_< _Tp >::ref | ( | int | i0, |
int | i1, | ||
size_t * | hashval = 0 |
||
) |
equivalent to SparseMat::ref<_Tp>(i0, i1, hashval)
Reimplemented from cv::SparseMat.
_Tp & cv::SparseMat_< _Tp >::ref | ( | int | i0, |
int | i1, | ||
int | i2, | ||
size_t * | hashval = 0 |
||
) |
equivalent to SparseMat::ref<_Tp>(i0, i1, i2, hashval)
Reimplemented from cv::SparseMat.
_Tp & cv::SparseMat_< _Tp >::ref | ( | const int * | idx, |
size_t * | hashval = 0 |
||
) |
equivalent to SparseMat::ref<_Tp>(idx, hashval)
Reimplemented from cv::SparseMat.
_Tp cv::SparseMat_< _Tp >::operator() | ( | int | i0, |
size_t * | hashval = 0 |
||
) | const |
equivalent to SparseMat::value<_Tp>(i0, hashval)
_Tp cv::SparseMat_< _Tp >::operator() | ( | int | i0, |
int | i1, | ||
size_t * | hashval = 0 |
||
) | const |
equivalent to SparseMat::value<_Tp>(i0, i1, hashval)
_Tp cv::SparseMat_< _Tp >::operator() | ( | int | i0, |
int | i1, | ||
int | i2, | ||
size_t * | hashval = 0 |
||
) | const |
equivalent to SparseMat::value<_Tp>(i0, i1, i2, hashval)
_Tp cv::SparseMat_< _Tp >::operator() | ( | const int * | idx, |
size_t * | hashval = 0 |
||
) | const |
equivalent to SparseMat::value<_Tp>(idx, hashval)
SparseMatIterator_< _Tp > cv::SparseMat_< _Tp >::begin | ( | ) |
returns sparse matrix iterator pointing to the first sparse matrix element
Reimplemented from cv::SparseMat.
SparseMatConstIterator_< _Tp > cv::SparseMat_< _Tp >::begin | ( | ) | const |
returns read-only sparse matrix iterator pointing to the first sparse matrix element
Reimplemented from cv::SparseMat.
SparseMatIterator_< _Tp > cv::SparseMat_< _Tp >::end | ( | ) |
returns sparse matrix iterator pointing to the element following the last sparse matrix element
Reimplemented from cv::SparseMat.
SparseMatConstIterator_< _Tp > cv::SparseMat_< _Tp >::end | ( | ) | const |
returns read-only sparse matrix iterator pointing to the element following the last sparse matrix element
Reimplemented from cv::SparseMat.
void cv::SparseMat::copyTo | ( | SparseMat & | m | ) | const [inherited] |
copies all the data to the destination matrix. All the previous content of m is erased
void cv::SparseMat::copyTo | ( | Mat & | m | ) | const [inherited] |
converts sparse matrix to dense matrix.
void cv::SparseMat::convertTo | ( | SparseMat & | m, |
int | rtype, | ||
double | alpha = 1 |
||
) | const [inherited] |
multiplies all the matrix elements by the specified scale factor alpha and converts the results to the specified data type
void cv::SparseMat::convertTo | ( | Mat & | m, |
int | rtype, | ||
double | alpha = 1 , |
||
double | beta = 0 |
||
) | const [inherited] |
converts sparse matrix to dense n-dim matrix with optional type conversion and scaling.
rtype | The output matrix data type. When it is =-1, the output array will have the same data type as (*this) |
alpha | The scale factor |
beta | The optional delta added to the scaled values before the conversion |
void cv::SparseMat::assignTo | ( | SparseMat & | m, |
int | type = -1 |
||
) | const [inherited] |
void cv::SparseMat::create | ( | int | dims, |
const int * | _sizes, | ||
int | _type | ||
) | [inherited] |
void cv::SparseMat::clear | ( | ) | [inherited] |
sets all the sparse matrix elements to 0, which means clearing the hash table.
void cv::SparseMat::addref | ( | ) | [inherited] |
manually increments the reference counter to the header.
void cv::SparseMat::release | ( | ) | [inherited] |
size_t cv::SparseMat::elemSize | ( | ) | const [inherited] |
returns the size of each element in bytes (not including the overhead - the space occupied by SparseMat::Node elements)
size_t cv::SparseMat::elemSize1 | ( | ) | const [inherited] |
returns elemSize()/channels()
const int * cv::SparseMat::size | ( | ) | const [inherited] |
returns the array of sizes, or NULL if the matrix is not allocated
int cv::SparseMat::size | ( | int | i | ) | const [inherited] |
returns the size of i-th matrix dimension (or 0)
int cv::SparseMat::dims | ( | ) | const [inherited] |
returns the matrix dimensionality
size_t cv::SparseMat::nzcount | ( | ) | const [inherited] |
returns the number of non-zero elements (=the number of hash table nodes)
size_t cv::SparseMat::hash | ( | int | i0 | ) | const [inherited] |
computes the element hash value (1D case)
size_t cv::SparseMat::hash | ( | int | i0, |
int | i1 | ||
) | const [inherited] |
computes the element hash value (2D case)
size_t cv::SparseMat::hash | ( | int | i0, |
int | i1, | ||
int | i2 | ||
) | const [inherited] |
computes the element hash value (3D case)
size_t cv::SparseMat::hash | ( | const int * | idx | ) | const [inherited] |
computes the element hash value (nD case)
uchar* cv::SparseMat::ptr | ( | int | i0, |
bool | createMissing, | ||
size_t * | hashval = 0 |
||
) | [inherited] |
specialized variants for 1D, 2D, 3D cases and the generic_type one for n-D case.
return pointer to the matrix element.
returns pointer to the specified element (1D case)
uchar* cv::SparseMat::ptr | ( | int | i0, |
int | i1, | ||
bool | createMissing, | ||
size_t * | hashval = 0 |
||
) | [inherited] |
returns pointer to the specified element (2D case)
uchar* cv::SparseMat::ptr | ( | int | i0, |
int | i1, | ||
int | i2, | ||
bool | createMissing, | ||
size_t * | hashval = 0 |
||
) | [inherited] |
returns pointer to the specified element (3D case)
uchar* cv::SparseMat::ptr | ( | const int * | idx, |
bool | createMissing, | ||
size_t * | hashval = 0 |
||
) | [inherited] |
returns pointer to the specified element (nD case)
_Tp cv::SparseMat::value | ( | int | i0, |
size_t * | hashval = 0 |
||
) | const [inherited] |
return value of the specified sparse matrix element.
value<_Tp>(i0,...[,hashval]) is equivalent
{ const _Tp* p = find<_Tp>(i0,...[,hashval]); return p ? *p : _Tp(); }
That is, if the element did not exist, the methods return 0. returns value of the specified element (1D case)
_Tp cv::SparseMat::value | ( | int | i0, |
int | i1, | ||
size_t * | hashval = 0 |
||
) | const [inherited] |
returns value of the specified element (2D case)
_Tp cv::SparseMat::value | ( | int | i0, |
int | i1, | ||
int | i2, | ||
size_t * | hashval = 0 |
||
) | const [inherited] |
returns value of the specified element (3D case)
_Tp cv::SparseMat::value | ( | const int * | idx, |
size_t * | hashval = 0 |
||
) | const [inherited] |
returns value of the specified element (nD case)
_Tp & cv::SparseMat::value | ( | Node * | n | ) | [inherited] |
returns the value stored in the sparse martix node
const _Tp & cv::SparseMat::value | ( | const Node * | n | ) | const [inherited] |
returns the value stored in the sparse martix node
const _Tp * cv::SparseMat::find | ( | int | i0, |
size_t * | hashval = 0 |
||
) | const [inherited] |
Return pointer to the specified sparse matrix element if it exists.
find<_Tp>(i0,...[,hashval]) is equivalent to (_const Tp*)ptr(i0,...false[,hashval]).
If the specified element does not exist, the methods return NULL. returns pointer to the specified element (1D case)
const _Tp * cv::SparseMat::find | ( | int | i0, |
int | i1, | ||
size_t * | hashval = 0 |
||
) | const [inherited] |
returns pointer to the specified element (2D case)
const _Tp * cv::SparseMat::find | ( | int | i0, |
int | i1, | ||
int | i2, | ||
size_t * | hashval = 0 |
||
) | const [inherited] |
returns pointer to the specified element (3D case)
const _Tp * cv::SparseMat::find | ( | const int * | idx, |
size_t * | hashval = 0 |
||
) | const [inherited] |
returns pointer to the specified element (nD case)
void cv::SparseMat::erase | ( | int | i0, |
int | i1, | ||
size_t * | hashval = 0 |
||
) | [inherited] |
erases the specified element (2D case)
void cv::SparseMat::erase | ( | int | i0, |
int | i1, | ||
int | i2, | ||
size_t * | hashval = 0 |
||
) | [inherited] |
erases the specified element (3D case)
void cv::SparseMat::erase | ( | const int * | idx, |
size_t * | hashval = 0 |
||
) | [inherited] |
erases the specified element (nD case)
SparseMat::Node * cv::SparseMat::node | ( | size_t | nidx | ) | [inherited] |
const SparseMat::Node * cv::SparseMat::node | ( | size_t | nidx | ) | const [inherited] |
uchar* cv::SparseMat::newNode | ( | const int * | idx, |
size_t | hashval | ||
) | [inherited] |
void cv::SparseMat::removeNode | ( | size_t | hidx, |
size_t | nidx, | ||
size_t | previdx | ||
) | [inherited] |
void cv::SparseMat::resizeHashTab | ( | size_t | newsize | ) | [inherited] |
int cv::SparseMat::flags [inherited] |
Hdr* cv::SparseMat::hdr [inherited] |