Implementation of the Mapping-interface which is able to represent arbitrary dimensional instances of Mappings by using a tree-like structure of sub-mappings, each representing the values for one of the dimensions. More...
#include <MappingUtils.h>
Inherits Mapping.
Public Member Functions | |
MultiDimMapping (const DimensionSet &myDims, InterpolationMethod intpl=STEPS) | |
Initializes the Mapping with the passed DimensionSet as domain. | |
MultiDimMapping (const DimensionSet &myDims, double oorv, InterpolationMethod intpl=STEPS) | |
Initializes the Mapping with the passed DimensionSet as domain. | |
MultiDimMapping (const MultiDimMapping< Interpolator > &o) | |
Copy-constructor which assures that the sub-mappings are deep copied instead of only their the pointers. | |
const MultiDimMapping & | operator= (const MultiDimMapping< Interpolator > &o) |
Copy operator which assures that the sub-mappings are deep copied instead of only their the pointers. | |
virtual Mapping * | clone () const |
returns a deep copy of this mapping instance. | |
virtual | ~MultiDimMapping () |
Frees the memory for the sub mappings. | |
virtual double | getValue (const Argument &pos) const |
Returns the value of this Mapping at position specified by the passed Argument. | |
virtual void | setValue (const Argument &pos, double value) |
Changes the value of the Mapping at the specified position. | |
virtual MappingIterator * | createIterator () |
Returns a pointer of a new Iterator which is able to iterate over the Mapping and can change the value the iterator points to. | |
virtual MappingIterator * | createIterator (const Argument &pos) |
Returns a pointer of a new Iterator which is able to iterate over the Mapping and can change the value the iterator points to. | |
Dimension | getDimension () |
Returns the dimension this instance represents. | |
Protected Types | |
typedef InterpolateableMap < double, Mapping *, Interpolator< double, Mapping *, std::map< double, Mapping * >::value_type, std::map< double, Mapping * > ::const_iterator > > | SubFunctionMap |
The type of the used InterpolateableMap. | |
Protected Member Functions | |
MultiDimMapping (const DimensionSet &myDims, Dimension myDim, InterpolationMethod intpl=STEPS) | |
Initializes the Mapping with the passed DimensionSet as domain and the passed dimension as the dimension this instance should represent. | |
MultiDimMapping (const DimensionSet &myDims, Dimension myDim, ConstantSimpleConstMapping *oorm, ConstMappingWrapper *wrappedoorm, InterpolationMethod intpl=STEPS) | |
Initializes the Mapping with the passed DimensionSet as domain and the passed dimension as the dimension this instance should represent. | |
MultiDimMapping (const MultiDimMapping< Interpolator > &o, ConstantSimpleConstMapping *oorm, ConstMappingWrapper *wrappedoorm) | |
Intern copy-constructor which assures that the sub-mappings are deep copied instead of only their pointers. | |
Mapping * | createSubSignal () const |
Internal helper method which creates a new sub-mapping for this MultiDimMapping instance. | |
void | copySubMappings (const MultiDimMapping &o) |
Protected Attributes | |
ConstantSimpleConstMapping * | outOfRangeMapping |
Returned by the Interpolator if the mapping is accessed outside its range (before or after the last key entry in a dimension). | |
ConstMappingWrapper * | wrappedOORMapping |
Wraps the out of range mapping which is an instance of ConstMapping inside an instance of Mapping which setValue method is asserted to never be called. | |
SubFunctionMap | entries |
Stores the sub-mappings for the dimension this instance represents. | |
Dimension | myDimension |
The dimension this instance represents. | |
bool | isMaster |
Friends | |
class | MultiDimMappingIterator< Interpolator > |
Implementation of the Mapping-interface which is able to represent arbitrary dimensional instances of Mappings by using a tree-like structure of sub-mappings, each representing the values for one of the dimensions.
This class internally uses a map of Mappings two represent one dimension. Where every Mapping in the map represents a sub-mapping for the values in the next dimension at that position in the this dimension. These sub-mappings can either be in turn MultiDimMappings with further sub-mappings or they can be TimedMappings if their dimension is the time. The TimedMappings therefore represent the leafs of the tree-like structure.
Definition at line 1286 of file MappingUtils.h.
MultiDimMapping< Interpolator >::MultiDimMapping | ( | const DimensionSet & | myDims, | |
Dimension | myDim, | |||
InterpolationMethod | intpl = STEPS | |||
) | [inline, protected] |
Initializes the Mapping with the passed DimensionSet as domain and the passed dimension as the dimension this instance should represent.
Also takes the interpolation method to use, but not yet implemented.
This constructor is only used internally to create the sub-mappings.
Definition at line 1325 of file MappingUtils.h.
: Mapping(myDims), outOfRangeMapping(0), wrappedOORMapping(0), entries(), myDimension(myDim), isMaster(false) {}
MultiDimMapping< Interpolator >::MultiDimMapping | ( | const DimensionSet & | myDims, | |
Dimension | myDim, | |||
ConstantSimpleConstMapping * | oorm, | |||
ConstMappingWrapper * | wrappedoorm, | |||
InterpolationMethod | intpl = STEPS | |||
) | [inline, protected] |
Initializes the Mapping with the passed DimensionSet as domain and the passed dimension as the dimension this instance should represent.
Also takes the interpolation method to use, but not yet implemented.
This constructor is only used internally to create the sub-mappings.
Definition at line 1341 of file MappingUtils.h.
: Mapping(myDims), outOfRangeMapping(oorm), wrappedOORMapping(wrappedoorm), entries(wrappedOORMapping), myDimension(myDim), isMaster(false) {}
MultiDimMapping< Interpolator >::MultiDimMapping | ( | const DimensionSet & | myDims, | |
InterpolationMethod | intpl = STEPS | |||
) | [inline] |
Initializes the Mapping with the passed DimensionSet as domain.
Also takes the interpolation-method but is not used yet.
Definition at line 1426 of file MappingUtils.h.
: Mapping(myDims), outOfRangeMapping(0), wrappedOORMapping(0), entries(), isMaster(true){ myDimension = *(dimensions.rbegin()); }
MultiDimMapping< Interpolator >::MultiDimMapping | ( | const DimensionSet & | myDims, | |
double | oorv, | |||
InterpolationMethod | intpl = STEPS | |||
) | [inline] |
Initializes the Mapping with the passed DimensionSet as domain.
Also takes the interpolation-method but is not used yet.
Definition at line 1441 of file MappingUtils.h.
: Mapping(myDims), outOfRangeMapping(new ConstantSimpleConstMapping(myDims, oorv)), wrappedOORMapping(new ConstMappingWrapper(outOfRangeMapping)), entries(wrappedOORMapping), isMaster(true) { myDimension = *(dimensions.rbegin()); }
virtual MappingIterator* MultiDimMapping< Interpolator >::createIterator | ( | const Argument & | pos | ) | [inline, virtual] |
Returns a pointer of a new Iterator which is able to iterate over the Mapping and can change the value the iterator points to.
The caller of this method has to delete the Iterator if not needed anymore.
Implements Mapping.
Reimplemented in FilledUpMapping.
Definition at line 1584 of file MappingUtils.h.
{ return new MultiDimMappingIterator<Interpolator>(*this, pos); }
virtual MappingIterator* MultiDimMapping< Interpolator >::createIterator | ( | ) | [inline, virtual] |
Returns a pointer of a new Iterator which is able to iterate over the Mapping and can change the value the iterator points to.
The caller of this method has to delete the Iterator if not needed anymore.
Implements Mapping.
Reimplemented in FilledUpMapping.
Definition at line 1573 of file MappingUtils.h.
{ return new MultiDimMappingIterator<Interpolator>(*this); }
virtual double MultiDimMapping< Interpolator >::getValue | ( | const Argument & | pos | ) | const [inline, virtual] |
Returns the value of this Mapping at position specified by the passed Argument.
Has logarithmic complexity over the number of dimensions and the number of entries per dimension.
Implements ConstMapping.
Definition at line 1534 of file MappingUtils.h.
Referenced by MultiDimMappingIterator< Linear >::MultiDimMappingIterator().
{ assert(pos.hasArgVal(myDimension)); double argVal = pos.getArgValue(myDimension); Interpolated<Mapping*> subM = entries.getIntplValue(argVal); if(!(*subM)) return double(); return (*subM)->getValue(pos); }
virtual void MultiDimMapping< Interpolator >::setValue | ( | const Argument & | pos, | |
double | value | |||
) | [inline, virtual] |
Changes the value of the Mapping at the specified position.
Has logarithmic complexity over the number of dimensions and the number of entries per dimension.
Implements Mapping.
Definition at line 1553 of file MappingUtils.h.
{ double argVal = pos.getArgValue(myDimension); typename SubFunctionMap::iterator posIt = entries.lower_bound(argVal); if(posIt == entries.end() || posIt->first != argVal) { Mapping* subF = createSubSignal(); posIt = entries.insert(posIt, typename SubFunctionMap::value_type(argVal, subF)); } posIt->second->setValue(pos, value); }