MRS  1.0
A C++ Class Library for Statistical Set Processing
subpavings::RangeCollectionHist Class Reference

List of all members.

Public Types

typedef cxsc::real RangeCollectionHistValueType
 Definition for the type for the values accessible from a rangeCollection.
typedef std::vector
< RangeCollectionHistValueType >
::const_iterator 
RangeCollectionHistItr
 Definition for the type for iterating through the values in a rangeCollection.

Public Member Functions

 RangeCollectionHist ()
 No-argument constructor.
 RangeCollectionHist (const RealVec &range)
 Constructor initialised with a container of values for the rangeCollection.
 RangeCollectionHist (const cxsc::real &r)
 Constructor initialised with a single value for the rangeCollection.
 RangeCollectionHist (const RangeCollectionHist &other)
 Copy constructor.
RangeCollectionHistoperator= (RangeCollectionHist rhs)
 Copy assignment operator.
RangeCollectionHistItr begin () const
 Return an iterator to the start of the collection.
RangeCollectionHistItr end () const
 Return an iterator to the end of the collection.
std::size_t getSize () const
 Get the size of this.
bool isEmpty () const
 Get whether the rangeCollection is empty.
RealVec getRangeCollectionValues () const
 Get a copy of the elements of this as a collection of reals.
cxsc::real getTotal () const
 Get the total of all the elements in this.
cxsc::real getAbsTotal () const
 Get the total of the absolute values of all the elements in this.
cxsc::real getAverageValue () const
 Get the average of all the elements in this.
RangeCollectionHist makeAverageRangeCollection () const
 Make a rangeCollection containing just the average of this.
RealVec getAbsDiffsToAverageRangeCollection () const
 Make a rangeCollection containing the absolute differences of each element to their average.
void reduce ()
 Reduce the rangeCollection to the sum of the present values.
void parallelAdd (const RangeCollectionHist &rhs)
 Add another the rangeCollection to this so that each element += parallel element in rhs.
RangeCollectionHistoperator+= (const RangeCollectionHist &rhs)
 Append the contents of another rangeCollection to this.
const RangeCollectionHist operator+ (const RangeCollectionHist &rhs) const
 Get the results of appending the contents of another rangeCollection to this.
RangeCollectionHistoperator*= (const cxsc::real &mult)
 Multiply every element in this by mult.
const RangeCollectionHist operator* (const cxsc::real &mult) const
 Get the results of multipling every element in this by mult.
RangeCollectionHistoperator/= (const cxsc::real &div)
 Divide every element in this by div.
const RangeCollectionHist operator/ (const cxsc::real &div) const
 Get the results of dividing every element in this by div.
bool checkRangeCollectionAllPositive () const
 Get whether the values in this are all positive.
void swap (RangeCollectionHist &other)
 Swap the contents of this and other.
Output this to an out stream with values

separated by tabs.

Parameters:
osis the stream to sent the output to.
precis the precision to use in the output.
std::ostream & outputTabs (std::ostream &os, int prec) const
std::ostream & outputTabs (std::ostream &os) const
Output the average of this to an out stream.
Parameters:
osis the stream to sent the output to.
precis the precision to use in the output.
std::ostream & outputAverage (std::ostream &os, int prec) const
std::ostream & outputAverage (std::ostream &os) const

Member Function Documentation

Return an iterator to the start of the collection.

The idiom for iterating through all the valuse in a rangeCollection rc is:

for (RangeCollectionHistItr it = rc.begin(); it < rc.end(), ++it) { ... }

{
  return container.begin();
}

Make a rangeCollection containing the absolute differences of each element to their average.

Throws an UnfulfillableRequest_Error if this is empty.

{
  RealVec result;
  result.reserve( getSize() );
  
  cxsc::real av = getAverageValue();
  for (RangeCollectionHistPrivateTypeConstItr cit = container.begin();
      cit < container.end(); ++cit) {
    result.push_back( cxsc::abs( (*cit) - av ) );
  }
  return result;
}

Get the average of all the elements in this.

Throws an UnfulfillableRequest_Error if this is empty.

{
  if ( isEmpty() ) {
    throw UnfulfillableRequest_Error("RangeCollectionHist::getAverageValue()");
  }
  return getTotal()/(1.0*getSize());
}
std::size_t RangeCollectionHist::getSize ( ) const

Get the size of this.

Size is number of elements in this.

{
  return container.size();
}

Get whether the rangeCollection is empty.

Returns:
true if this has no elements, false otherwise.
{
  return container.empty();
}

Make a rangeCollection containing just the average of this.

Throws an UnfulfillableRequest_Error if this is empty.

const RangeCollectionHist RangeCollectionHist::operator/ ( const cxsc::real &  div) const

Get the results of dividing every element in this by div.

Throws a std::invalid_argument exception if div == 0.0.

{
  RangeCollectionHist result = *this;     
  result /= div;            
  return result; 
}
RangeCollectionHist & RangeCollectionHist::operator/= ( const cxsc::real &  div)

Divide every element in this by div.

Throws a std::invalid_argument exception if div == 0.0.

{
  if (div == 0.0) {
    throw std::invalid_argument("RangeCollectionHist::operator/= : divide by zero");
  }
  
  cxsc::real realMult = 1.0/cxsc::real(div);
  
  this->scalarMult(realMult);
    
  return *this;
}

Add another the rangeCollection to this so that each element += parallel element in rhs.

Throws a std::logic_error exception if this and rhs are different sizes.

{
  if (getSize() != rhs.getSize() ) {
    throw std::logic_error(
      "RangeCollectionHist::parallelAdd(const RangeCollectionHist&) : collections of different sizes");
  }
  
  std::transform(container.begin(), container.end(), 
      rhs.begin(), container.begin(),
      std::plus<RangeCollectionHistPrivateValueType>() );
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations Friends