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

A wrapper or manager for a collection of RealMappedShapeNodes representing a polygon 'paving' with real values mapped to each polygon-shaped piece in the 'paving'. More...

List of all members.

Public Member Functions

 PolygonPiecewiseConstantFunction (const PiecewiseConstantFunction &pcf, const std::vector< std::vector< double > > &backtransform, const std::vector< double > &scale, const std::vector< double > &shift)
 Constructor with a transformation matrix.
 PolygonPiecewiseConstantFunction (const PiecewiseConstantFunction &pcf, const std::vector< double > &scale, const std::vector< double > &shift)
 Constructor with no transformation matrix.
 PolygonPiecewiseConstantFunction (const PiecewiseConstantFunction &pcf, const std::vector< std::vector< double > > &backtransform, const std::vector< double > &scale, const std::vector< double > &shift, cxsc::real cov)
 Constructor with a transformation matrix and a coverage value.
 PolygonPiecewiseConstantFunction (const PiecewiseConstantFunction &pcf, const std::vector< double > &scale, const std::vector< double > &shift, cxsc::real cov)
 Constructor with no transformation matrix but specifying a coverage value.
 PolygonPiecewiseConstantFunction (const PolygonPiecewiseConstantFunction &other)
 ~PolygonPiecewiseConstantFunction ()
 Destructor.
PolygonPiecewiseConstantFunctionoperator= (PolygonPiecewiseConstantFunction rhs)
 Copy assignment operator.
int getDimensions () const
 get the dimensions of the subpaving this manages.
Output the pieces of this to a txt file.

Format is tab-delimited file of numeric data starting with nodeName, then the node value, then the vertices of the box.

Parameters:
sthe name of the txt file to send output to.
precthe precision for output formatting. ie, number of decimal places.
confirmis a boolean controlling whether confirmation goes to console output.
void outputToTxtTabs (const std::string &s, int prec=5) const
void outputToTxtTabs (const std::string &s, int prec, bool confirm) const
Output the pieces of this to a stream.

Format is tab-delimited file of numeric data starting with nodeName, then the node value, then the vertices of the box.

Parameters:
osthe name of the txt file to send output to.
precthe precision for output formatting. ie, number of decimal places.
confirmis a boolean controlling whether confirmation goes to console output.
std::ostream & outputToStreamTabs (std::ostream &os, int prec=5) const
Output the area pieces of this to a txt file.

The area pieces are the coordinates representing the 'floor area' or domain of this, ie have no 'height' or range.

Format is tab-delimited file of numeric data starting with nodeName (X), then the node value (0.0), then the vertices of the box.

Parameters:
sthe name of the txt file to send output to.
precthe precision for output formatting. ie, number of decimal places.
confirmis a boolean controlling whether confirmation goes to console output.
void outputAreaToTxtTabs (const std::string &s, int prec=5) const
void outputAreaToTxtTabs (const std::string &s, int prec, bool confirm) const

Output the area pieces of this to a stream.

The area pieces are the coordinates representing the 'floor area' or domain of this, ie have no 'height' or range.

Format is tab-delimited file of numeric data starting with nodeName (X), then the node value (0.0), then the vertices of the box.

Parameters:
osthe name of the txt file to send output to.
precthe precision for output formatting. ie, number of decimal places.
confirmis a boolean controlling whether confirmation goes to console output.
std::ostream & outputAreaToStreamTabs (std::ostream &os, int prec=5) const
void swap (PolygonPiecewiseConstantFunction &pcf)
 Swap this and another PolygonPiecewiseConstantFunction.

Detailed Description

A wrapper or manager for a collection of RealMappedShapeNodes representing a polygon 'paving' with real values mapped to each polygon-shaped piece in the 'paving'.

A PolygonPiecewiseConstantFunction is a representation of a piecewise-constant function on a domain that is not necessarily an axis-aligned hyper-rectangle and where the pieces are not necessarily axis-aligned hyper-rectangles.

A PolygonPiecewiseConstantFunction may be formed by transforming a PiecewiseConstantFunction (ie a representation of a piecewise-constant function where the pieces are the pieces of an axis-aligned regular paving). The transformations can include rotation, reflection, scaling, and translation, ie transformations that preserve angles.

A PolygonPiecewiseConstantFunction also hold its area pieces, describing the 'floor area' or domain of the function it represents (ie have no 'height' or range). The area pieces will describe disjoint areas if this represents a function over a domain of disjoint parts, but where possible the different pieces in the domain will have been joined together so that the domain is described by as few area pieces as possible.


Constructor & Destructor Documentation

PolygonPiecewiseConstantFunction::PolygonPiecewiseConstantFunction ( const PiecewiseConstantFunction pcf,
const std::vector< std::vector< double > > &  backtransform,
const std::vector< double > &  scale,
const std::vector< double > &  shift 
)

Constructor with a transformation matrix.

This is constructed by applying a volume and angle-preserving back-transformation to the boxes in the PiecewiseConstantFunction pcf, then scaling as specifed in scale, then shifting as specified in shift.

The back-transformation is specified by the matrix represented by backtransform.

The scaling is specifed by the elements of scale. The ith element of scale is the scalar to be applied on the ith dimension of this.

The shifting is specifed by the elements of shift. The ith element of shidft is the shift to be applied on the ith dimension of this.

The polygon-subpaving managed by this will have as many pieces as pcf and each piece will be the result of applying the back-transformation matrix backtransform to the equivalent piece in pcf, scaling it and shifting it, and then giving it a constant value equal to the contstant value on the equivalent piece in pcf divided by the product of the elements in scale (ie adjusting for the change in the volume of the domain that results from scaling the shapes in this).

Parameters:
pcfthe PiecewiseConstantFunction to use to provide the subpaving structure for this and the constant values to be adjusted for volume scaling to give the values on the pieces of this.
backtransformA representation of a volume preserving and angle preserving back-transformation matrix specified in row major order, ie the inner vectors of backtransform are the rows of the back-transformation matrix.
scaleThe scaling to be applied on each dimension. The ith element of scale is the scalar on the ith dimension of this.
shiftThe shift to be applied on each dimension. The ith element of shift is the translation on the ith dimension of this.
Precondition:
backtransform should represent a square matrix of dimension d where d is also the dimension of the subpaving managed by pcf.
backtransform should be a volume-preserving transformation matrix.
scale and shift should both also be of dimension d.
scale should contain only strictly positive values.
Postcondition:
This will have the same total integral as pcf.
{
    try {
    
    RealMappedSPnode::ConstPtrs pieces;
    std::vector < cxsc::ivector > boxes;
    pcf.getPieces(pieces); 
    boxes.push_back(pcf.getRootBox());     
        
    fillNodes(pieces, boxes, backtransform, scale, shift);
        
  }
    catch (exception const& e) {
    constructor_error_handler();
    }
}
PolygonPiecewiseConstantFunction::PolygonPiecewiseConstantFunction ( const PiecewiseConstantFunction pcf,
const std::vector< double > &  scale,
const std::vector< double > &  shift 
)

Constructor with no transformation matrix.

This is constructed by scaling as specifed in scale, then shifting as specified in shift.

The scaling is specifed by the elements of scale. The ith element of scale is the scalar to be applied on the ith dimension of this.

The shifting is specifed by the elements of shift. The ith element of shidft is the shift to be applied on the ith dimension of this.

The polygon-subpaving managed by this will have as many pieces as pcf and each piece will be the result of scaling and shifting the equivalent piece in pcf and then giving it a constant value equal to the contstant value on the equivalent piece in pcf divided by the product of the elements in scale (ie adjusting for the change in the volume of the domain that results from scaling the shapes in this).

Parameters:
pcfthe PiecewiseConstantFunction to use to provide the subpaving structure for this and the constant values to be adjusted for volume scaling to give the values on the pieces of this.
scaleThe scaling to be applied on each dimension. The ith element of scale is the scalar on the ith dimension of this.
shiftThe shift to be applied on each dimension. The ith element of shift is the translation on the ith dimension of this.
Precondition:
scale and shift should both also be of dimension d where d is the dimension of the subpaving managed by pcf.
scale should contain only strictly positive values.
Postcondition:
This will have the same total integral as pcf.
{
    try {
        
        RealMappedSPnode::ConstPtrs pieces;
    std::vector < cxsc::ivector > boxes;
    pcf.getPieces(pieces); 
    boxes.push_back(pcf.getRootBox());       
        
    fillNodes(pieces, boxes, scale, shift);
    
  }
    catch (exception const& e) {
    constructor_error_handler();
    }
}
PolygonPiecewiseConstantFunction::PolygonPiecewiseConstantFunction ( const PiecewiseConstantFunction pcf,
const std::vector< std::vector< double > > &  backtransform,
const std::vector< double > &  scale,
const std::vector< double > &  shift,
cxsc::real  cov 
)

Constructor with a transformation matrix and a coverage value.

This is constructed by taking the cov coverage pieces of pcf and applying a volume and angle-preserving back-transformation to them, then scaling them as specifed in scale, then shifting them as specified in shift.

The coverage pieces for a given value of cov is one of the the (possibly non-unique): smallest sets of pieces of pcf such that the sum of the "areas" of those pieces is >= cov * total sum of the "areas" of the pieces of pcf. The "area" of a piece of a PiecewiseConstantFunction is the product of the volume of the box associated with the piece and the value on the piece.

The back-transformation is specified by the matrix represented by backtransform.

The scaling is specifed by the elements of scale. The ith element of scale is the scalar to be applied on the ith dimension of this.

The shifting is specifed by the elements of shift. The ith element of shidft is the shift to be applied on the ith dimension of this.

The polygon-subpaving managed by this will have as many pieces as the smallest size of the set of pieces of pcf such that the set covers cov of the total integral of pcf, and each piece will be the result of applying the back-transformation matrix backtransform to the equivalent piece in pcf, scaling it and shifting it, and then giving it a constant value equal to the contstant value on the equivalent piece in pcf divided by the product of the elements in scale (ie adjusting for the change in the volume of the domain that results from scaling the shapes in this).

Parameters:
pcfthe PiecewiseConstantFunction to use to provide the subpaving structure for this and the constant values to be adjusted for volume scaling to give the values on the pieces of this.
backtransformA representation of a volume preserving and angle preserving back-transformation matrix specified in row major order, ie the inner vectors of backtransform are the rows of the back-transformation matrix.
scaleThe scaling to be applied on each dimension. The ith element of scale is the scalar on the ith dimension of this.
shiftThe shift to be applied on each dimension. The ith element of shift is the translation on the ith dimension of this.
covThe minimum proportion of the total integral of pcf to be represented in the pieces of pcf used to form this: the pieces used to form this will be one of the smallest possible sets of pieces of pcf representing at least cov of the total integral of pcf.
Precondition:
backtransform should represent a square matrix of dimension d where d is also the dimension of the subpaving managed by pcf.
backtransform should be a volume-preserving transformation matrix.
scale and shift should both also be of dimension d.
scale should contain only strictly positive values.
Postcondition:
This will have integral >= cov multiplied by the total integral of pcf.
{
    try {
        
        RealMappedSPnode::ConstPtrs pieces;
    std::vector < cxsc::ivector > boxes;
    pcf.findCoverageRegion(pieces, boxes, cov);        
        
    fillNodes(pieces, boxes, backtransform, scale, shift);
    
  }
    catch (exception const& e) {
    constructor_error_handler();
    }
}
PolygonPiecewiseConstantFunction::PolygonPiecewiseConstantFunction ( const PiecewiseConstantFunction pcf,
const std::vector< double > &  scale,
const std::vector< double > &  shift,
cxsc::real  cov 
)

Constructor with no transformation matrix but specifying a coverage value.

This is constructed by taking the cov coverage pieces of pcf and then scaling these pieces as specifed in scale, then shifting them as specified in shift.

The coverage pieces for a given value of cov is one of the the (possibly non-unique): smallest sets of pieces of pcf such that the sum of the "areas" of those pieces is >= cov * total sum of the "areas" of the pieces of pcf. The "area" of a piece of a PiecewiseConstantFunction is the product of the volume of the box associated with the piece and the value on the piece.

The scaling is specifed by the elements of scale. The ith element of scale is the scalar to be applied on the ith dimension of this.

The shifting is specifed by the elements of shift. The ith element of shidft is the shift to be applied on the ith dimension of this.

The polygon-subpaving managed by this will have as many pieces as the smallest size of the set of pieces of pcf such that the set covers cov of the total integral of pcf, and each piece will be the result of scaling and shifting the equivalent piece in pcf and then giving it a constant value equal to the contstant value on the equivalent piece in pcf divided by the product of the elements in scale (ie adjusting for the change in the volume of the domain that results from scaling the shapes in this).

Parameters:
pcfthe PiecewiseConstantFunction to use to provide the subpaving structure for this and the constant values to be adjusted for volume scaling to give the values on the pieces of this.
scaleThe scaling to be applied on each dimension. The ith element of scale is the scalar on the ith dimension of this.
shiftThe shift to be applied on each dimension. The ith element of shift is the translation on the ith dimension of this.
covThe minimum proportion of the total integral of pcf to be represented in the pieces of pcf used to form this: the pieces used to form this will be one of the smallest possible sets of pieces of pcf representing at least cov of the total integral of pcf.
Precondition:
scale and shift should both also be of dimension d where d is the dimension of the subpaving managed by pcf.
scale should contain only strictly positive values.
Postcondition:
This will have integral >= cov multiplied by the total integral of pcf.
{
    try {
        
        RealMappedSPnode::ConstPtrs pieces;
    std::vector < cxsc::ivector > boxes;
    pcf.findCoverageRegion(pieces, boxes, cov); 
    
    fillNodes(pieces, boxes, scale, shift);
    
  }
    catch (exception const& e) {
    constructor_error_handler();
    }
}

Member Function Documentation

get the dimensions of the subpaving this manages.

Returns:
0 if this does not have a subpaving, else returns the dimensions of the subpaving.
{
   return nodes.front()->getDimension();
  
}

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