OpenWalnut  1.5.0dev
Public Types | Public Member Functions | Private Types | Private Attributes | List of all members
WHistogram2D Class Reference

Uniform two dimensional histogram for double values. More...

#include <WHistogram2D.h>

+ Inheritance diagram for WHistogram2D:
+ Collaboration diagram for WHistogram2D:

Public Types

typedef std::shared_ptr< WHistogram2DSPtr
 Convenience type for a shared_ptr on this type. More...
 
- Public Types inherited from WHistogramND< 2 >
typedef boost::array< size_t, N > SizeArray
 Shorthand for N-dimensional indices, counter, etc. More...
 
typedef boost::array< double, N > TArray
 Shorthand for N-dimensional values of type T. More...
 

Public Member Functions

 WHistogram2D (double minX, double maxX, double minY, double maxY, size_t bucketsX, size_t bucketsY)
 Creates a two dimensional histogram field, bounded by the given limits, containing the demanded number of buckets in each dimension. More...
 
 ~WHistogram2D ()
 Cleans up! More...
 
 WHistogram2D (const WHistogram2D &other)
 Copy constructor, performing a deep copy. More...
 
virtual size_t operator() (SizeArray index) const
 Get the count of the specified bucket. More...
 
virtual size_t operator() (size_t i, size_t j) const
 Convenience function to easier access the buckets for 2D. More...
 
virtual double getBucketSize (SizeArray index) const
 Return the measure of one specific bucket. More...
 
virtual boost::array< std::pair< double, double >, 2 > getIntervalForIndex (SizeArray index) const
 Returns the actual (right-open) interval in each dimension associated with the given index. More...
 
void insert (TArray values)
 Given a value the corresponding bucket is determined and incremented by one. More...
 
void insert (double x, double y)
 Shorthand to overloaded insert function where each dimension can be overhanded separately. More...
 
WGETexture2D::RPtr getTexture ()
 Copy-convert this into a texture. More...
 
WGETexture2D::RPtr getSphereTexture ()
 Copy-convert this into a spherical texture. More...
 
- Public Member Functions inherited from WHistogramND< 2 >
 WHistogramND (TArray min, TArray max, SizeArray buckets)
 Default constructor. More...
 
 WHistogramND (const WHistogramND &hist)
 Copy constructor. More...
 
virtual ~WHistogramND ()
 Default destructor. More...
 
virtual size_t operator() (SizeArray index) const=0
 Get the count of the specified bucket. More...
 
virtual size_t size () const
 Returns the number of buckets in the HistogramND with the actual mapping. More...
 
virtual TArray getMinima () const
 Returns the minimum value(s). More...
 
virtual TArray getMaxima () const
 Returns the maximum value(s). More...
 
virtual double getBucketSize (SizeArray index) const=0
 Return the measure of one specific bucket. More...
 
virtual boost::array< std::pair< double, double >, N > getIntervalForIndex (SizeArray index) const=0
 Returns the actual (right-open) interval in each dimension associated with the given index. More...
 

Private Types

typedef Eigen::Matrix< size_t, Eigen::Dynamic, Eigen::Dynamic > BinType
 Shorthand for data structure storing bucket information. More...
 

Private Attributes

BinType m_bins
 Storing the bucket counts, how often a value occurs. More...
 
TArray m_intervalWidth
 For each dimension this stores the uniform interval width. More...
 

Additional Inherited Members

- Protected Member Functions inherited from WHistogramND< 2 >
 WHistogramND ()
 Default constructor is protected to allow subclassing constructors not to use initialization lists which would imply C++11 or GNU++11 style initializers for boost::array members. More...
 
void reset (TArray min, TArray max, SizeArray buckets)
 Initializes all members. More...
 
- Protected Attributes inherited from WHistogramND< 2 >
TArray m_min
 The smallest value in each dimension. More...
 
TArray m_max
 The biggest value in each dimension. More...
 
SizeArray m_buckets
 The number of buckets. More...
 
size_t m_nbBuckets
 Total number of buckets. More...
 

Detailed Description

Uniform two dimensional histogram for double values.

The terms bin and bucket are interchangeable. For the first dimensional part often the analouge X-dimension is used and for the second, Y-dimension.

Definition at line 41 of file WHistogram2D.h.

Member Typedef Documentation

◆ BinType

typedef Eigen::Matrix< size_t, Eigen::Dynamic, Eigen::Dynamic > WHistogram2D::BinType
private

Shorthand for data structure storing bucket information.

In 2D this is a matrix.

Definition at line 145 of file WHistogram2D.h.

◆ SPtr

typedef std::shared_ptr< WHistogram2D > WHistogram2D::SPtr

Convenience type for a shared_ptr on this type.

Definition at line 47 of file WHistogram2D.h.

Constructor & Destructor Documentation

◆ WHistogram2D() [1/2]

WHistogram2D::WHistogram2D ( double  minX,
double  maxX,
double  minY,
double  maxY,
size_t  bucketsX,
size_t  bucketsY 
)

Creates a two dimensional histogram field, bounded by the given limits, containing the demanded number of buckets in each dimension.

Parameters
minXMinimal bound for X-values.
maxXMaximal bound for X-values.
minYMinimal bound for Y-values.
maxYMaximal bound for Y-values.
bucketsXNumber of buckets in X direction.
bucketsYNumber of buckets in Y direction.

Definition at line 34 of file WHistogram2D.cpp.

References m_bins, m_intervalWidth, and WHistogramND< 2 >::reset().

+ Here is the call graph for this function:

◆ ~WHistogram2D()

WHistogram2D::~WHistogram2D ( )

Cleans up!

Definition at line 47 of file WHistogram2D.cpp.

◆ WHistogram2D() [2/2]

WHistogram2D::WHistogram2D ( const WHistogram2D other)

Copy constructor, performing a deep copy.

Parameters
otherThe other instance to copy from.

Definition at line 51 of file WHistogram2D.cpp.

References m_bins.

Member Function Documentation

◆ getBucketSize()

double WHistogram2D::getBucketSize ( SizeArray  index) const
virtual

Return the measure of one specific bucket.

For one dimensional Histograms this is the width of the bucket, for two dimensions this is the area, for three dims this is the volume, etc.

Parameters
indexthe measure for this bucket is queried.
Returns
the size of a bucket.

Definition at line 68 of file WHistogram2D.cpp.

References m_intervalWidth.

◆ getIntervalForIndex()

boost::array< std::pair< double, double >, 2 > WHistogram2D::getIntervalForIndex ( SizeArray  index) const
virtual

Returns the actual (right-open) interval in each dimension associated with the given index.

Parameters
indexfor this bucket the intervals will be returned
Returns
the right-open interval in each dimension.

Definition at line 73 of file WHistogram2D.cpp.

References m_intervalWidth, and WHistogramND< 2 >::m_min.

◆ getSphereTexture()

WGETexture2D::RPtr WHistogram2D::getSphereTexture ( )

Copy-convert this into a spherical texture.

Spherical means hereby, that buckets representing areas near the poles have scaled counters.

Returns
osg::ref_ptr to the two-dimensional spherical texture.

Definition at line 168 of file WHistogram2D.cpp.

References m_bins, and WHistogramND< 2 >::m_buckets.

◆ getTexture()

WGETexture2D::RPtr WHistogram2D::getTexture ( )

Copy-convert this into a texture.

Returns
osg::ref_ptr to the two-dimensional texture.

Definition at line 123 of file WHistogram2D.cpp.

References m_bins, and WHistogramND< 2 >::m_buckets.

◆ insert() [1/2]

void WHistogram2D::insert ( double  x,
double  y 
)

Shorthand to overloaded insert function where each dimension can be overhanded separately.

See also
insert()
Parameters
xvalue for the first dimension.
yvalue for the second dimension.

Definition at line 117 of file WHistogram2D.cpp.

References insert().

+ Here is the call graph for this function:

◆ insert() [2/2]

void WHistogram2D::insert ( TArray  values)

Given a value the corresponding bucket is determined and incremented by one.

Parameters
valuesThe value to count into specific bucket.

Definition at line 86 of file WHistogram2D.cpp.

References wlimits::DBL_EPS, m_bins, WHistogramND< 2 >::m_buckets, m_intervalWidth, WHistogramND< 2 >::m_max, WHistogramND< 2 >::m_min, and wlog::warn().

Referenced by insert(), WHistogram2DTest::testInsert(), WHistogram2DTest::testInsertAlmostMax(), WHistogram2DTest::testInsertMax(), WHistogram2DTest::testInsertMin(), WHistogram2DTest::testInsertOnIntervalBorder(), and WHistogram2DTest::testInsertOutOfBounds().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator()() [1/2]

size_t WHistogram2D::operator() ( size_t  i,
size_t  j 
) const
virtual

Convenience function to easier access the buckets for 2D.

Parameters
iX-index
jY-index
Returns
elements in the bucket.

Definition at line 62 of file WHistogram2D.cpp.

References operator()().

+ Here is the call graph for this function:

◆ operator()() [2/2]

size_t WHistogram2D::operator() ( SizeArray  index) const
virtual

Get the count of the specified bucket.

Parameters
indexin each dimension
Returns
elements in the bucket.

Definition at line 57 of file WHistogram2D.cpp.

References m_bins.

Referenced by operator()().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_bins

BinType WHistogram2D::m_bins
private

Storing the bucket counts, how often a value occurs.

Definition at line 150 of file WHistogram2D.h.

Referenced by getSphereTexture(), getTexture(), insert(), operator()(), and WHistogram2D().

◆ m_intervalWidth

TArray WHistogram2D::m_intervalWidth
private

For each dimension this stores the uniform interval width.

Definition at line 155 of file WHistogram2D.h.

Referenced by getBucketSize(), getIntervalForIndex(), insert(), and WHistogram2D().


The documentation for this class was generated from the following files: