Main Page   Class Hierarchy   Alphabetical List   Compound List   Compound Members  

prapi::Distribution Class Reference

#include <Distribution.h>

Inheritance diagram for prapi::Distribution:

List of all members.

Detailed Description

Distribution is a multi-dimensional list that can be accessed linearly as any list.


Public Methods

 Distribution (int length)
 Create a one-dimensional distribution.

 Distribution (const List< int > &dimensions)
 Create a new multi-dimensional distribution.

 Distribution (const Distribution &other)
 Create a copy of other.

Distribution & operator= (const Distribution &other)
 Set this distribution to be equal to other.

void normalize (void)
 Normalize the distribution by dividing each element by the sum of all elements.

void setElementAt (const List< int > &coordinates, double value)
 Set the value of a distribution entry.

double getElementAt (const List< int > &coordinates) const
 Get the value of a distribution entry.

double & elementAt (const List< int > &coordinates)
 Get the value of a distribution entry.

Distribution getMarginalDistribution (int dimension) const
 Calculate a marginal distribution by "flattening", i.e.

template<class T> void addDistribution (const List< T > &lst) throw (InvalidArgumentException&)
 Add the corresponding entries in lst to this distribution.

template<class T> void subtractDistribution (const List< T > &lst) throw (InvalidArgumentException&)
 Remove the corresponding entries in lst from this distribution.

template<class T> void operator+= (const List< T > &other)
 Add the corresponding entries in other to this distribution.

template<class T> void operator-= (const List< T > &other)
 Remove the corresponding entries in other from this distribution.


Friends

Distribution operator * (const Distribution &dist, double value)
 Multiply all values in the distribution by a constant value.

Distribution operator/ (const Distribution &dist, double value)
 Divide all values in the distribution by a constant value.

template<class T> Distribution & operator+ (Distribution &dist, List< T > &other)
 Sum two distributions together.

template<class T> Distribution & operator- (Distribution &dist, List< T > &other)
 Subtract two distributions from each other.


Constructor & Destructor Documentation

prapi::Distribution::Distribution int    length
 

Create a one-dimensional distribution.

Parameters:
length  the length of the single dimension

prapi::Distribution::Distribution const List< int > &    dimensions
 

Create a new multi-dimensional distribution.

Parameters:
dimensions  the lengths of each dimension. The size of this list determines the number of dimensions, and each value in the list determines the length of the corresponding dimension.


Member Function Documentation

double& prapi::Distribution::elementAt const List< int > &    coordinates
 

Get the value of a distribution entry.

Parameters:
coordinates  the coordinates of the entry. The length of this list must equal to the number of dimensions in this distribution.
Returns:
the value in the given coordinates

double prapi::Distribution::getElementAt const List< int > &    coordinates const
 

Get the value of a distribution entry.

Parameters:
coordinates  the coordinates of the entry. The length of this list must equal to the number of dimensions in this distribution.
Returns:
the value in the given coordinates

Distribution prapi::Distribution::getMarginalDistribution int    dimension const
 

Calculate a marginal distribution by "flattening", i.e.

integrating over the given dimension.

Parameters:
dimension  a zero-based dimension index
Returns:
a new distribution with a number of dimensions one less than in the current distribution.

template<class T>
void prapi::Distribution::operator+= const List< T > &    other [inline]
 

Add the corresponding entries in other to this distribution.

Note: in List, this operator concatenates two Lists.

template<class T>
void prapi::Distribution::operator-= const List< T > &    other [inline]
 

Remove the corresponding entries in other from this distribution.

Note: in List, this operator removes entries from the target list.

void prapi::Distribution::setElementAt const List< int > &    coordinates,
double    value
 

Set the value of a distribution entry.

Parameters:
coordinates  the coordinates of the entry. The length of this list must equal to the number of dimensions in this distribution.
value  the new value


Friends And Related Function Documentation

template<class T>
Distribution& operator+ Distribution &    dist,
List< T > &    other
[friend]
 

Sum two distributions together.

See also:
operator+=(List)

template<class T>
Distribution& operator- Distribution &    dist,
List< T > &    other
[friend]
 

Subtract two distributions from each other.

See also:
operator-=(List)


The documentation for this class was generated from the following files:
Documentation generated on 11.09.2003 with Doxygen.
The documentation is copyrighted material.
Copyright © Topi Mäenpää 2003. All rights reserved.