last update 20 Sep 2009 |
#include <cvrLattice1D.h>
Public Types | |
Internal types and classes | |
typedef cvr::constReferenceException | constReferenceException |
typedef genericLattice1D< T > ::value_type | value_type |
typedef genericLattice1D< T > ::size_type | size_type |
typedef genericLattice1D< T > ::pointer | pointer |
typedef genericLattice1D< T > ::const_pointer | const_pointer |
typedef genericLattice1D< T > ::reference | reference |
typedef genericLattice1D< T > ::const_reference | const_reference |
typedef genericLattice1D< T > ::iterator | iterator |
typedef genericLattice1D< T > ::const_iterator | const_iterator |
Public Member Functions | |
lattice1D () | |
lattice1D (const size_type from, const size_type to) | |
lattice1D (const iinterval &indices) | |
lattice1D (const size_type from, const size_type to, const_reference iniValue) | |
lattice1D (const iinterval &indices, const_reference iniValue) | |
lattice1D (const size_type from, const size_type to, const value_type data[]) | |
lattice1D (const iinterval &indices, const value_type data[]) | |
lattice1D (const size_type from, const size_type to, value_type data[], const eConstantReference constRef) | |
lattice1D (const iinterval &indices, value_type data[], const eConstantReference constRef) | |
lattice1D (const genericLattice1D< T > &other) | |
lattice1D (const genericLattice1D< T > &other, const size_type from, const size_type to=container::MaxIndex) | |
lattice1D (const genericLattice1D< T > &other, const iinterval &indices) | |
lattice1D (const std::vector< T > &other, const int firstIndex=0) | |
lattice1D (const genericVector< T > &other, const int firstIndex=0) | |
virtual | ~lattice1D () |
const std::string & | name () const |
virtual lattice1D< T > * | clone () const |
virtual lattice1D< T > * | newInstance () const |
bool | prettyCloseTo (const genericLattice1D< T > &other, const T &tolerance) const |
Arithmetical Operations | |
T | dot (const genericLattice1D< T > &other) const |
lattice1D< T > & | emultiply (const genericLattice1D< T > &other) |
lattice1D< T > & | emultiply (const genericLattice1D< T > &first, const genericLattice1D< T > &second) |
lattice1D< T > & | edivide (const genericLattice1D< T > &other) |
lattice1D< T > & | edivide (const genericLattice1D< T > &first, const genericLattice1D< T > &second) |
lattice1D< T > & | edivide (const T cst) |
lattice1D< T > & | edivide (const genericLattice1D< T > &other, const T cst) |
lattice1D< T > & | add (const genericLattice1D< T > &other) |
lattice1D< T > & | add (const genericLattice1D< T > &first, const genericLattice1D< T > &second) |
lattice1D< T > & | add (const T cst) |
lattice1D< T > & | add (const genericLattice1D< T > &other, const T cst) |
lattice1D< T > & | operator+= (const T cst) |
lattice1D< T > & | operator+= (const genericLattice1D< T > &other) |
lattice1D< T > & | addScaled (const T b, const genericLattice1D< T > &other) |
lattice1D< T > & | addScaled (const T a, const genericLattice1D< T > &first, const T b, const genericLattice1D< T > &second) |
lattice1D< T > & | addScaled (const genericLattice1D< T > &first, const T b, const genericLattice1D< T > &second) |
lattice1D< T > & | subtract (const T cst) |
lattice1D< T > & | subtract (const genericLattice1D< T > &other, const T cst) |
lattice1D< T > & | subtract (const genericLattice1D< T > &other) |
lattice1D< T > & | subtract (const genericLattice1D< T > &first, const genericLattice1D< T > &second) |
lattice1D< T > & | operator-= (const genericLattice1D< T > &other) |
lattice1D< T > & | operator-= (const T cst) |
lattice1D< T > & | multiply (const T cst) |
lattice1D< T > & | multiply (const genericLattice1D< T > &other, const T cst) |
lattice1D< T > & | operator*= (const T cst) |
lattice1D< T > & | divide (const T cst) |
lattice1D< T > & | divide (const genericLattice1D< T > &other, const T cst) |
lattice1D< T > & | operator/= (const T cst) |
T | computeSumOfElements () const |
T | computeProductOfElements () const |
Find extreme values | |
T | findMinimum () const |
int | findIndexOfMinimum () const |
T | findMaximum () const |
int | findIndexOfMaximum () const |
void | findExtremes (T &theMinimum, T &theMaximum) const |
void | findIndexOfExtremes (int &theIdxMinimum, int &theIdxMaximum) const |
This container is inspired on mathematical integer lattices, at least with respect to the indices, which are taken from in the general case with $n=1$ in this particular case.
You can consider this a generalization of a cvr::vector, in which the index of the first element is not necessarily zero, but a negative or positive value.
The main goal of this class is to provide a fast implementation for random access containers, addressable with negative indices, like filter kernels, and since speed is the premise, it is achieved at some memory costs. This means this class has some storage overhead in order to provide some information at zero time, like size, first and last indices the begin and end iterators, etc., which is only possible by storing them directly.
Additionally to all functionality of the genericLattice1D, this class provides additional arithmetical and mathematical operations.
The following types are supported by cvr::lattice1D:
This restriction is done to avoid the typical template code explosion due to frequently used types in the library. If you need the lattice1D as container of any other type, consider using cvr::genericLattice1D.
The lattice1D class is a container class implemented as template, where the template type T denotes the type of the elements. It is by no means a generic container, since the types it supports must fulfill many requirements, specially support for all arithmetical operators, and the types supported are explicitely instantiated in the library.
typedef genericLattice1D<T>::const_iterator cvr::lattice1D< T >::const_iterator |
const_iterator
type (allows read-only operations).
The use of the iterator classes is similar to the iterators of the STL (Standard Template Library). See cvr::genericLattice1D::begin() for an example.
For the debugging version of the iterators, boundary check will be done! This explains the low speed of the iterators of the debug version. In the release version, no boundary check will be done, and the iterators are sometimes a factor 10 faster than the debug iterators.
The use of the access operator at() is faster than the iterators in the debug version only. If you need to iterate on a genericLattice1D use iterators instead (in the release version iterators are approximately a factor 3 faster than at()).
Reimplemented from cvr::genericLattice1D< T >.
Reimplemented in cvr::kernel1D< T >.
typedef genericLattice1D<T>::const_pointer cvr::lattice1D< T >::const_pointer |
Const pointer to value_type.
Reimplemented from cvr::genericLattice1D< T >.
Reimplemented in cvr::kernel1D< T >.
typedef genericLattice1D<T>::const_reference cvr::lattice1D< T >::const_reference |
Const reference to value_type.
Reimplemented from cvr::genericLattice1D< T >.
Reimplemented in cvr::kernel1D< T >.
typedef cvr::constReferenceException cvr::lattice1D< T >::constReferenceException |
Exception thrown when a constant reference is violated.
Reimplemented from cvr::genericLattice1D< T >.
typedef genericLattice1D<T>::iterator cvr::lattice1D< T >::iterator |
iterator
type (allows read and write operations).
The use of the iterator classes is similar to the iterators of the STL (Standard Template Library). See cvr::genericLattice1D::begin() and cvr::genericLattice1D::inverseBegin() for examples.
For the debugging version of the iterators, boundary check will be done! This explains the low speed of the iterators of the debug version. In the release version, no boundary check will be done, and the iterators are sometimes a factor 10 faster than the debug iterators.
The use of the access operator at() is faster than the iterators in the debug version only. If you need to iterate on a genericLattice1D use iterators instead (in the release version iterators are approximately a factor 3 faster than at()).
Reimplemented from cvr::genericLattice1D< T >.
Reimplemented in cvr::kernel1D< T >.
typedef genericLattice1D<T>::pointer cvr::lattice1D< T >::pointer |
Pointer to value_type.
Reimplemented from cvr::genericLattice1D< T >.
Reimplemented in cvr::kernel1D< T >.
typedef genericLattice1D<T>::reference cvr::lattice1D< T >::reference |
Reference to value_type.
Reimplemented from cvr::genericLattice1D< T >.
Reimplemented in cvr::kernel1D< T >.
typedef genericLattice1D<T>::size_type cvr::lattice1D< T >::size_type |
Return type of the size() member.
Reimplemented from cvr::genericLattice1D< T >.
Reimplemented in cvr::kernel1D< T >.
typedef genericLattice1D<T>::value_type cvr::lattice1D< T >::value_type |
Type of the genericLattice1D elements.
Reimplemented from cvr::genericLattice1D< T >.
Reimplemented in cvr::kernel1D< T >.
cvr::lattice1D< T >::lattice1D | ( | ) |
Default constructor creates an empty lattice1D;.
cvr::lattice1D< T >::lattice1D | ( | const size_type | from, | |
const size_type | to | |||
) | [explicit] |
cvr::lattice1D< T >::lattice1D | ( | const iinterval & | indices | ) | [explicit] |
cvr::lattice1D< T >::lattice1D | ( | const size_type | from, | |
const size_type | to, | |||
const_reference | iniValue | |||
) | [explicit] |
cvr::lattice1D< T >::lattice1D | ( | const iinterval & | indices, | |
const_reference | iniValue | |||
) | [explicit] |
cvr::lattice1D< T >::lattice1D | ( | const size_type | from, | |
const size_type | to, | |||
const value_type | data[] | |||
) |
Create a lattice1D indexed by the given interval and initialize it with the given data.
The data will be copied.
If you need to just use the memory block without copying it, then you can wether use a third parameter of eConstantReference type or later call the useExternData() method.
from | initial index value | |
to | final index value | |
data | a pointer to the data that will be copied. |
cvr::lattice1D< T >::lattice1D | ( | const iinterval & | indices, | |
const value_type | data[] | |||
) |
Create a lattice1D indexed by the given interval and initialize it with the given data.
The data will be copied.
If you need to just use the memory block without copying it, then you can wether use a third parameter of eConstantReference type or later call the useExternData() method.
indices | index interval | |
data | a pointer to the data that will be copied. |
cvr::lattice1D< T >::lattice1D | ( | const size_type | from, | |
const size_type | to, | |||
value_type | data[], | |||
const eConstantReference | constRef | |||
) |
Create a lattice1D indexed by the given interval and initialize it with the given data, the same way "useExternData" does, i.e.
the data will not be copied!.
from | initial index | |
to | final index | |
data | a pointer to the data that will be used. | |
constRef | if this parameter is ConstantReference it will not be possible to change the pointer to the external memory block nor to resize the lattice1D. Despite this, the value of each element can be changed by the access operators. |
cvr::lattice1D< T >::lattice1D | ( | const iinterval & | indices, | |
value_type | data[], | |||
const eConstantReference | constRef | |||
) |
Create a lattice1D indexed by the given interval and initialize it with the given data, the same way "useExternData" does, i.e.
the data will not be copied!.
indices | interval used for the lattice indices | |
data | a pointer to the data that will be used. | |
constRef | if this parameter is ConstantReference it will not be possible to change the pointer to the external memory block nor to resize the lattice1D. Despite this, the value of each element can be changed by the access operators. |
cvr::lattice1D< T >::lattice1D | ( | const genericLattice1D< T > & | other | ) |
cvr::lattice1D< T >::lattice1D | ( | const genericLattice1D< T > & | other, | |
const size_type | from, | |||
const size_type | to = container::MaxIndex | |||
) |
cvr::lattice1D< T >::lattice1D | ( | const genericLattice1D< T > & | other, | |
const iinterval & | indices | |||
) |
cvr::lattice1D< T >::lattice1D | ( | const std::vector< T > & | other, | |
const int | firstIndex = 0 | |||
) |
cvr::lattice1D< T >::lattice1D | ( | const genericVector< T > & | other, | |
const int | firstIndex = 0 | |||
) |
Create this lattice1D as a copy of another cvr::genericVector.
virtual cvr::lattice1D< T >::~lattice1D | ( | ) | [virtual] |
Destructor.
lattice1D<T>& cvr::lattice1D< T >::add | ( | const genericLattice1D< T > & | other, | |
const T | cst | |||
) |
lattice1D<T>& cvr::lattice1D< T >::add | ( | const T | cst | ) |
lattice1D<T>& cvr::lattice1D< T >::add | ( | const genericLattice1D< T > & | first, | |
const genericLattice1D< T > & | second | |||
) |
lattice1D<T>& cvr::lattice1D< T >::add | ( | const genericLattice1D< T > & | other | ) |
lattice1D<T>& cvr::lattice1D< T >::addScaled | ( | const genericLattice1D< T > & | first, | |
const T | b, | |||
const genericLattice1D< T > & | second | |||
) |
Leave the addition of the first lattice1D and the second lattice1D scaled with the given factor in this lattice1D.
The lattice1Ds must be of the same types and dimensions. Let A be the first lattice1D and B the second lattice1D with corresponding scaling factor b, further C this lattice1D, then this method performs:
If both lattice1Ds have different size, an assertion will be thrown
first | the first lattice1D to be added after scaling | |
b | scaling factor for second | |
second | the second lattice1D to be added after scaling |
lattice1D<T>& cvr::lattice1D< T >::addScaled | ( | const T | a, | |
const genericLattice1D< T > & | first, | |||
const T | b, | |||
const genericLattice1D< T > & | second | |||
) |
Leave the scaled sum of two lattice1Ds in this lattice1D.
The lattice1Ds must be of the same types and dimensions. Let A be the first lattice1D and B the second lattice1D with corresponding scaling factors a and b, further C this lattice1D, then this method performs:
If both lattice1Ds have different size, an assertion will be thrown
a | scaling factor for first | |
first | the first lattice1D to be added after scaling | |
b | scaling factor for second | |
second | the second lattice1D to be added after scaling |
lattice1D<T>& cvr::lattice1D< T >::addScaled | ( | const T | b, | |
const genericLattice1D< T > & | other | |||
) |
Add another lattice1D scaled by b to this lattice1D.
The lattice1Ds must be of the same types and dimensions. Let A be this lattice1D and B the other lattice1D, then this method performs:
If both lattice1Ds have different size, an assertion will be thrown
b | scaling factor for other | |
other | the lattice1D to be added after scaling |
virtual lattice1D<T>* cvr::lattice1D< T >::clone | ( | ) | const [virtual] |
Create a clone of this lattice1D.
Reimplemented from cvr::genericLattice1D< T >.
Reimplemented in cvr::kernel1D< T >.
T cvr::lattice1D< T >::computeProductOfElements | ( | ) | const |
Calculate the product of all elements of the lattice1D.
This member can be used with classes which define the operator '*='
T cvr::lattice1D< T >::computeSumOfElements | ( | ) | const |
Calculate the sum of all elements of the lattice1D.
This member can be used with classes which define the operator '+='
lattice1D<T>& cvr::lattice1D< T >::divide | ( | const genericLattice1D< T > & | other, | |
const T | cst | |||
) |
lattice1D<T>& cvr::lattice1D< T >::divide | ( | const T | cst | ) |
T cvr::lattice1D< T >::dot | ( | const genericLattice1D< T > & | other | ) | const |
Dot product with another lattice1D of the same type.
The dot product of lattices is here defined as the sum of the products of elements sharing the same indices. If the lattices have different definition intervals, then only the common interval will be considered (as it will be assumed that the other lattice has a zero in all other undefined elements.
other | the other lattice1D to be multiplied with |
lattice1D<T>& cvr::lattice1D< T >::edivide | ( | const genericLattice1D< T > & | other, | |
const T | cst | |||
) | [inline] |
Divide the other lattice1D with a constant and leave the result here.
Returns a reference to this lattice1D.
synonym for divide(const lattice1D<T>& other,const T cst).
other | the lattice1D to be divide by the constant value | |
cst | the elements of the lattice1D will be divided with this constant |
lattice1D<T>& cvr::lattice1D< T >::edivide | ( | const T | cst | ) | [inline] |
lattice1D<T>& cvr::lattice1D< T >::edivide | ( | const genericLattice1D< T > & | first, | |
const genericLattice1D< T > & | second | |||
) |
lattice1D<T>& cvr::lattice1D< T >::edivide | ( | const genericLattice1D< T > & | other | ) |
Elementwise division.
Each element of this lattice1D will be divided by the elements of the other lattice1D and the result will be left in this object! The returned lattice1D is this object!
If both lattice1Ds have different definition intervals, an assertion will be thrown.
other | the other lattice1D to be divided by |
lattice1D<T>& cvr::lattice1D< T >::emultiply | ( | const genericLattice1D< T > & | first, | |
const genericLattice1D< T > & | second | |||
) |
Elementwise multiplication.
This lattice1D will contain the elementwise multiplication of the elements in first and second.
If both lattice1Ds have different definition intervals, an assertion will be thrown.
first | the first lattice1D | |
second | the second lattice1D will be multiplied with the first lattice1D |
lattice1D<T>& cvr::lattice1D< T >::emultiply | ( | const genericLattice1D< T > & | other | ) |
Elementwise multiplication.
Each element of this lattice1D will be multiplied with the corresponding elements of the other lattice1D and the result will be left in this object!
If both lattice1Ds have different definition intervals, an assertion will be thrown.
other | the other lattice1D to be multiplied with |
void cvr::lattice1D< T >::findExtremes | ( | T & | theMinimum, | |
T & | theMaximum | |||
) | const |
Find the extremes of the lattice1D (smallest and biggest elements).
void cvr::lattice1D< T >::findIndexOfExtremes | ( | int & | theIdxMinimum, | |
int & | theIdxMaximum | |||
) | const |
Find the indices of the extremes of the lattice1D (smallest and biggest elements).
int cvr::lattice1D< T >::findIndexOfMaximum | ( | ) | const |
Find the index of the biggest element of the lattice1D.
int cvr::lattice1D< T >::findIndexOfMinimum | ( | ) | const |
Find the index of the smallest element of the lattice1D.
T cvr::lattice1D< T >::findMaximum | ( | ) | const |
Find the biggest element of the lattice1D.
T cvr::lattice1D< T >::findMinimum | ( | ) | const |
Find the smallest element of the lattice1D.
lattice1D<T>& cvr::lattice1D< T >::multiply | ( | const genericLattice1D< T > & | other, | |
const T | cst | |||
) |
Multiply the other lattice1D with a constant and leave the result here.
Returns a reference to this lattice1D. If both lattice1Ds have different size, an assertion will be thrown
other | the other lattice1D to be multiplied with the constant value | |
cst | constant scalar to be multiplied with the other lattice1D. |
lattice1D<T>& cvr::lattice1D< T >::multiply | ( | const T | cst | ) |
const std::string& cvr::lattice1D< T >::name | ( | ) | const [virtual] |
Returns the name of this class.
Reimplemented from cvr::genericLattice1D< T >.
Reimplemented in cvr::kernel1D< T >.
virtual lattice1D<T>* cvr::lattice1D< T >::newInstance | ( | ) | const [virtual] |
Create a new lattice1D instance.
Reimplemented from cvr::genericLattice1D< T >.
Reimplemented in cvr::kernel1D< T >.
lattice1D<T>& cvr::lattice1D< T >::operator*= | ( | const T | cst | ) |
lattice1D<T>& cvr::lattice1D< T >::operator+= | ( | const genericLattice1D< T > & | other | ) | [inline] |
Alias for add(const lattice1D<T>& other).
lattice1D<T>& cvr::lattice1D< T >::operator+= | ( | const T | cst | ) | [inline] |
Alias for add(const T cst).
lattice1D<T>& cvr::lattice1D< T >::operator-= | ( | const T | cst | ) |
Alias for subtract(const T& cst).
lattice1D<T>& cvr::lattice1D< T >::operator-= | ( | const genericLattice1D< T > & | other | ) | [inline] |
Alias for substract(const lattice1D<T>& other) If both lattice1Ds have different size, an assertion will be thrown.
lattice1D<T>& cvr::lattice1D< T >::operator/= | ( | const T | cst | ) |
Alias for divide(const T& cst).
bool cvr::lattice1D< T >::prettyCloseTo | ( | const genericLattice1D< T > & | other, | |
const T & | tolerance | |||
) | const |
Compare this lattice1D with other
, and use the given tolerance to determine if the value of each element of the other lattice1D approximately equals the values of the actual lattice1D elements.
An element x is approximately equal to another element y with a tolerance t, if following equation holds: x-t < y < x+t.
Both lattices must have exactly the same definition interval. Otherwise false
is returned.
other | the other lattice1D to be compared with | |
tolerance | the tolerance to be used |
lattice1D<T>& cvr::lattice1D< T >::subtract | ( | const genericLattice1D< T > & | first, | |
const genericLattice1D< T > & | second | |||
) |
lattice1D<T>& cvr::lattice1D< T >::subtract | ( | const genericLattice1D< T > & | other | ) |
lattice1D<T>& cvr::lattice1D< T >::subtract | ( | const genericLattice1D< T > & | other, | |
const T | cst | |||
) |
lattice1D<T>& cvr::lattice1D< T >::subtract | ( | const T | cst | ) |