IGLib 1.4
The IGLib base library for development of numerical, technical and business applications.
|
Class that is used to calculate and compare distances between point containers. More...
Classes | |
class | StoredDistanceComparerClass |
Compares two point containers according to their StoredDistance property. More... | |
Public Member Functions | |
DistanceComparer (PointContainerType referencePoint, DistanceDelegate< PointType > distanceFunction) | |
Constructs a new comparer according to input distance to a reference poiont (type IVector). | |
DistanceComparer (PointContainerType referencePoint, DistanceDelegate< PointType > distanceFunction, IVector lengthScales) | |
Constructs a new comparer according to input distance to a reference poiont (type IVector). | |
abstract void | GetPointCoordinates (PointType pt, ref IVector coord) |
Gets vector of coordinates of the specified point and stores it in the specified variable. Where the type of point object itself contains vector of coordinates, only reference is stored. The obtained vector should therefore not be modified in any way. | |
void | SetCoordinateScales (IVector min, IVector max, IVector lengthScales) |
Sets parameters that affect default calculation of distance and relative point coordinates. | |
void | GetRelativeCoordinates (IVector coord, ref IVector relativeCoortinates) |
Converts the specified coordinates to relative coordinates where compponents run from 0 to 1 if original coordinates run from minimal to maximal value. Minimal coordinate values are stored in Min and maximal values are stored in Max. | |
void | SetOutputScales (IVector min, IVector max, IVector lengthScales) |
Sets parameters that affect default calculation of output distance and output relative coordinates. | |
void | GetOutputRelativeCoordinates (IVector coord, ref IVector relativeCoortinates) |
Converts the specified OUTPUT coordinates to relative coordinates where compponents run from 0 to 1 if original coordinates run from minimal to maximal value. Minimal OUTPUT coordinate values are stored in OutputMin and maximal values are stored in OutputMax. | |
virtual double | OutputDistance (PointContainerType pt1, PointContainerType pt2) |
Returns output distance between two point containers. If vector of output scales (property OutputLengthScales) is specified then weighted Euclidean distance between output vectors of the specified containers is returned (differences in components are divided by components of vector output scaling lengths before being squared).If vector of output length scales is not specified then usual Euclidean distance between coordinates of the two specified points is returned. | |
virtual int | Compare (PointContainerType pt1, PointContainerType pt2) |
Compares two points according to the current comparer definition. | |
virtual double | Distance (PointType pt1, PointType pt2) |
Returns distance between the specified two points. | |
double | Distance (PointContainerType boxedPt1, PointContainerType boxedPt2) |
Returns distance between the specified two points enclosed in PointContainer objects, as defined by the distance calculation delegate (property DistanceFunction) of the current object. | |
double | Distance (PointContainerType boxedPt1, PointType pt2) |
Returns distance between the specified point encolosed in an PointContainer object and a non-enclosed point, as defined by the distance calculation delegate (property DistanceFunction) of the current object. | |
double | Distance (PointType pt1, PointContainerType boxedPt2) |
Returns distance between the specified point and the second point encolosed in an PointContainer object, as defined by the distance calculation delegate (property DistanceFunction) of the current object. | |
double | Distance (PointType pt) |
Returns distance between the specified point and the reference point (property ReferencePoint) of the current object (enclosed in PointContainer<PointType> object), as defined by the distance calculation delegate of the current comparer object (property DistanceFunction). | |
double | Distance (PointContainerType boxedPt) |
Returns distance between the specified point (enclosed in PointContainer<PointType> pbject) and the reference point (property ReferencePoint) of the current object (property ReferencePoint), as defined by the distance calculation delegate of the current comparer object (property DistanceFunction). | |
void | Sort (List< PointContainerType > list) |
Sorts a list of point containers with the current comparer. | |
void | SortUsingStoredDistance (List< PointContainerType > list) |
Sorts a list of point containers with the current comparer. | |
Protected Member Functions | |
virtual double | OutputDistance (IVector outVec1, IVector outVec2) |
Returns output distance between two output vectors. If vector of output scales (property OutputLengthScales) is specified then weighted Euclidean distance between coordinates of the specified point is returned (differences in coordinates are divided by components of vector of scales before being squared).If vector of output length scales is not specified then usual Euclidean distance between coordinates of the two specified points is returned. | |
virtual double | DefaultDistanceFunction (PointType pt1, PointType pt2) |
Default distance funciton for the current class, used when distance calculation delegate is not specified. If vector of length scales (property LengthScales) is specified then weighted Euclidean distance between coordinates of the specified point is returned (differences in coordinates are divided by components of this vector before being squared).Iv vector of length scales is not specified then Euclidean distance between coordinates of the two specified points is returned. | |
Protected Attributes | |
PointContainerType | _referencePoint |
DistanceDelegate< PointType > | _distanceFunction |
IVector | _lengthScales = null |
IVector | _min = null |
IVector | _max = null |
IVector | _outputLengthScales = null |
IVector | _outputMin = null |
IVector | _outputMax = null |
Properties | |
object | Lock [get] |
This object's central lock object to be used by other object. Do not use this object for locking in class' methods, for this you should use InternalLock. | |
PointContainerType | ReferencePoint [get, set] |
Reference point. Points are compared with respect to the distance to this point. | |
DistanceDelegate< PointType > | DistanceFunction [get, set] |
Delegate that calculates distance between two vectors. If set to nul then default distance function (DefaultDistanceFunction) is used for distance calculation. | |
IVector | LengthScales [get, set] |
Sets the vector of length scales that are used for calculation of distances. Property has protected setter. | |
IVector | Min [get, set] |
Sets the vector of minimal values for point coordinates. Needed for calculation of relative coordinate vector. Property has protected setter. | |
IVector | Max [get, set] |
Sets the vector of maximal values point coordinates. Needed for calculation of relative coordinate vector. Property has protected setter. | |
IVector | OutputLengthScales [get, set] |
Sets the vector of OUTPUT vector's length scales that are used for calculation of distances and relative coordinates. Property has protected setter. | |
IVector | OutputMin [get, set] |
Sets the vector of minimal values for point OUTPUT values. Needed for calculation of relative coordinate vector. Property has protected setter. | |
IVector | OutputMax [get, set] |
Sets the vector of maximal values point OUTPUT values. Needed for calculation of relative coordinate vector. Property has protected setter. | |
IComparer< PointContainerType > | StoredDistanceComparer [get] |
Gets comparer that compares two point containers of type PointContainerType by the stored distance stored on those points. | |
Private Member Functions | |
DistanceComparer () | |
Private Attributes | |
object | _mainLock = new object() |
IComparer< PointContainerType > | _storedDistanceComparer |
Class that is used to calculate and compare distances between point containers.
PointType | Type of the point objects that have a point position in space, and whose containers of type PointContainer<PointType> are compared by the current class. |
PointContainerType | Type of point container that is used to wrap points of the point type. |
This class as a part of group of classes that have been created in 2008 in order to support different operations and algorithms on losely connected clouds of points that are embedded in space of arbitrary dimension. The primary intended application was in optimization algorithms based on successive approximations of response and on restricted step prototype algorithms, developed by the author. The scope is much broader, however, because these classes can support closest neighbors algorithms, various graph algorithms based on points in space, detection of clusters, etc.
In 2009, major refactoring has been performed where a more generic structure has been introduced, allowing implementation of generic algorithm methods that can be used with different representations of points.
In 2011, the classes weer migrated from sandbox environment to the prduction IGLib library and simplified a bit. The intention is to use the classes in the artificial neural network-based approximation modules developed for COBIK and the University of Nova Gorica. The intention is, however, that the eventual algorithms developed within this scope are implemented in a generic way, such that they can serve multiple purposes.
$A Igor Sep08 May09 Dec11;
PointContainerType | : | IPointContainer<PointType> |
IG::Num::DistanceComparer< PointContainerType, PointType >::DistanceComparer | ( | ) | [inline, private] |
IG::Num::DistanceComparer< PointContainerType, PointType >::DistanceComparer | ( | PointContainerType | referencePoint, |
DistanceDelegate< PointType > | distanceFunction | ||
) | [inline] |
Constructs a new comparer according to input distance to a reference poiont (type IVector).
referencePoint | Reference point. Training elements are compared by their distance to this point. |
distanceFunction | Delegate used for calculation of distance between two points. |
immutable | If true then a copy of the reference point is stored internally rather than just its reference, so it can not be changed. |
IG::Num::DistanceComparer< PointContainerType, PointType >::DistanceComparer | ( | PointContainerType | referencePoint, |
DistanceDelegate< PointType > | distanceFunction, | ||
IVector | lengthScales | ||
) | [inline] |
Constructs a new comparer according to input distance to a reference poiont (type IVector).
referencePoint | Reference point. Training elements are compared by their distance to this point. |
distanceFunction | Delegate used for calculation of distance between two points. |
immutable | If true then a copy of the reference point is stored internally rather than just its reference, so it can not be changed. |
abstract void IG::Num::DistanceComparer< PointContainerType, PointType >::GetPointCoordinates | ( | PointType | pt, |
ref IVector | coord | ||
) | [pure virtual] |
Gets vector of coordinates of the specified point and stores it in the specified variable. Where the type of point object itself contains vector of coordinates, only reference is stored. The obtained vector should therefore not be modified in any way.
pt | Point for which vector of coordinates is obtained. |
coord | Vector variable where extracted vector of coordinates is stored. |
Implements IG::Num::IDistanceComparer< PointContainerType, PointType >.
void IG::Num::DistanceComparer< PointContainerType, PointType >::SetCoordinateScales | ( | IVector | min, |
IVector | max, | ||
IVector | lengthScales | ||
) | [inline] |
Sets parameters that affect default calculation of distance and relative point coordinates.
min | Vector of minimal coordinates. |
max | Vector of maximal coordinates. |
lengthScales | Vector of length scales. |
Implements IG::Num::IDistanceComparer< PointContainerType, PointType >.
void IG::Num::DistanceComparer< PointContainerType, PointType >::GetRelativeCoordinates | ( | IVector | coord, |
ref IVector | relativeCoortinates | ||
) | [inline] |
Converts the specified coordinates to relative coordinates where compponents run from 0 to 1 if original coordinates run from minimal to maximal value. Minimal coordinate values are stored in Min and maximal values are stored in Max.
coord | Vector of original coordinates. |
relativeCoortinates | Vector where converted relative coordinates are stored. |
Calculation of relative coordinates does not rely on the vector of length scales, but only on vectors of minimal and maximal coordinates.
Implements IG::Num::IDistanceComparer< PointContainerType, PointType >.
void IG::Num::DistanceComparer< PointContainerType, PointType >::SetOutputScales | ( | IVector | min, |
IVector | max, | ||
IVector | lengthScales | ||
) | [inline] |
Sets parameters that affect default calculation of output distance and output relative coordinates.
min | Vector of minimal output coordinates. |
max | Vector of maximal output coordinates. |
lengthScales | Vector of output length scales. |
Implements IG::Num::IDistanceComparer< PointContainerType, PointType >.
void IG::Num::DistanceComparer< PointContainerType, PointType >::GetOutputRelativeCoordinates | ( | IVector | coord, |
ref IVector | relativeCoortinates | ||
) | [inline] |
Converts the specified OUTPUT coordinates to relative coordinates where compponents run from 0 to 1 if original coordinates run from minimal to maximal value. Minimal OUTPUT coordinate values are stored in OutputMin and maximal values are stored in OutputMax.
coord | Vector of original coordinates. |
relativeCoortinates | Vector where converted relative OUTPUT coordinates are stored. |
Calculation of relative coordinates does not rely on the vector of length scales, but only on vectors of minimal and maximal coordinates.
This functionality is used only in those types of points that have input parameters and output values, such as approximation data points.
Implements IG::Num::IDistanceComparer< PointContainerType, PointType >.
virtual double IG::Num::DistanceComparer< PointContainerType, PointType >::OutputDistance | ( | PointContainerType | pt1, |
PointContainerType | pt2 | ||
) | [inline, virtual] |
Returns output distance between two point containers. If vector of output scales (property OutputLengthScales) is specified then weighted Euclidean distance between output vectors of the specified containers is returned (differences in components are divided by components of vector output scaling lengths before being squared).If vector of output length scales is not specified then usual Euclidean distance between coordinates of the two specified points is returned.
pt1 | The first poiint container for distance calculation. |
pt2 | The second point container for distance calculation. |
This functionality is used only in those types of points that have input parameters and output values, such as approximation data points.
While definition of input distance (between point co-ordinates) can be defined by a delegate, definition of output distance is currenyly fixed, can not be modified (except by setting the vector of output length scales that affects the definition).
Implements IG::Num::IDistanceComparer< PointContainerType, PointType >.
virtual double IG::Num::DistanceComparer< PointContainerType, PointType >::OutputDistance | ( | IVector | outVec1, |
IVector | outVec2 | ||
) | [inline, protected, virtual] |
Returns output distance between two output vectors. If vector of output scales (property OutputLengthScales) is specified then weighted Euclidean distance between coordinates of the specified point is returned (differences in coordinates are divided by components of vector of scales before being squared).If vector of output length scales is not specified then usual Euclidean distance between coordinates of the two specified points is returned.
outVec1 | The first output vector for output distance calculation. |
outVec2 | The second output vector for output distance calculation. |
This functionality is used only in those types of points that have input parameters and output values, such as approximation data points.
While definition of input distance (between point co-ordinates) can be defined by a delegate, definition of output distance is currenyly fixed, can not be modified (except by setting the vector of output length scales that affects the definition).
virtual double IG::Num::DistanceComparer< PointContainerType, PointType >::DefaultDistanceFunction | ( | PointType | pt1, |
PointType | pt2 | ||
) | [inline, protected, virtual] |
Default distance funciton for the current class, used when distance calculation delegate is not specified. If vector of length scales (property LengthScales) is specified then weighted Euclidean distance between coordinates of the specified point is returned (differences in coordinates are divided by components of this vector before being squared).Iv vector of length scales is not specified then Euclidean distance between coordinates of the two specified points is returned.
pt1 | The first poiint for distance calculation. |
pt2 | The second point for distance calculation. |
virtual int IG::Num::DistanceComparer< PointContainerType, PointType >::Compare | ( | PointContainerType | pt1, |
PointContainerType | pt2 | ||
) | [inline, virtual] |
Compares two points according to the current comparer definition.
pt1 | the first point to be compared. |
pt2 | The second point to be compared. |
virtual double IG::Num::DistanceComparer< PointContainerType, PointType >::Distance | ( | PointType | pt1, |
PointType | pt2 | ||
) | [inline, virtual] |
Returns distance between the specified two points.
pt1 | The first point. |
pt2 | The second point. |
Distance is defined by the DistanceFunction property, which is a delegate of type DistanceDelegate<PointType>.
Implements IG::Num::IDistanceComparer< PointContainerType, PointType >.
double IG::Num::DistanceComparer< PointContainerType, PointType >::Distance | ( | PointContainerType | boxedPt1, |
PointContainerType | boxedPt2 | ||
) | [inline] |
Returns distance between the specified two points enclosed in PointContainer objects, as defined by the distance calculation delegate (property DistanceFunction) of the current object.
boxedPt1 | The first point. |
boxedPt2 | The second point. |
Implements IG::Num::IDistanceComparer< PointContainerType, PointType >.
double IG::Num::DistanceComparer< PointContainerType, PointType >::Distance | ( | PointContainerType | boxedPt1, |
PointType | pt2 | ||
) | [inline] |
Returns distance between the specified point encolosed in an PointContainer object and a non-enclosed point, as defined by the distance calculation delegate (property DistanceFunction) of the current object.
boxedPt1 | The first training element. |
pt2 | The second training element. |
Implements IG::Num::IDistanceComparer< PointContainerType, PointType >.
double IG::Num::DistanceComparer< PointContainerType, PointType >::Distance | ( | PointType | pt1, |
PointContainerType | boxedPt2 | ||
) | [inline] |
Returns distance between the specified point and the second point encolosed in an PointContainer object, as defined by the distance calculation delegate (property DistanceFunction) of the current object.
pt1 | The first point. |
boxedPt2 | The second point enclosed in PointContainer<PointType> object. |
Implements IG::Num::IDistanceComparer< PointContainerType, PointType >.
double IG::Num::DistanceComparer< PointContainerType, PointType >::Distance | ( | PointType | pt | ) | [inline] |
Returns distance between the specified point and the reference point (property ReferencePoint) of the current object (enclosed in PointContainer<PointType> object), as defined by the distance calculation delegate of the current comparer object (property DistanceFunction).
pt | Vector whose distance to the reference point is returned. |
Implements IG::Num::IDistanceComparer< PointContainerType, PointType >.
double IG::Num::DistanceComparer< PointContainerType, PointType >::Distance | ( | PointContainerType | boxedPt | ) | [inline] |
Returns distance between the specified point (enclosed in PointContainer<PointType> pbject) and the reference point (property ReferencePoint) of the current object (property ReferencePoint), as defined by the distance calculation delegate of the current comparer object (property DistanceFunction).
pt | Pont enclosed in an PointContainer object whose distance to the reference point is returned. |
Implements IG::Num::IDistanceComparer< PointContainerType, PointType >.
void IG::Num::DistanceComparer< PointContainerType, PointType >::Sort | ( | List< PointContainerType > | list | ) | [inline] |
Sorts a list of point containers with the current comparer.
list | List of point containers to be sorted. |
Implements IG::Num::IDistanceComparer< PointContainerType, PointType >.
void IG::Num::DistanceComparer< PointContainerType, PointType >::SortUsingStoredDistance | ( | List< PointContainerType > | list | ) | [inline] |
Sorts a list of point containers with the current comparer.
list | List of point containers to be sorted. |
Implements IG::Num::IDistanceComparer< PointContainerType, PointType >.
object IG::Num::DistanceComparer< PointContainerType, PointType >::_mainLock = new object() [private] |
PointContainerType IG::Num::DistanceComparer< PointContainerType, PointType >::_referencePoint [protected] |
DistanceDelegate<PointType> IG::Num::DistanceComparer< PointContainerType, PointType >::_distanceFunction [protected] |
IVector IG::Num::DistanceComparer< PointContainerType, PointType >::_lengthScales = null [protected] |
IVector IG::Num::DistanceComparer< PointContainerType, PointType >::_min = null [protected] |
IVector IG::Num::DistanceComparer< PointContainerType, PointType >::_max = null [protected] |
IVector IG::Num::DistanceComparer< PointContainerType, PointType >::_outputLengthScales = null [protected] |
IVector IG::Num::DistanceComparer< PointContainerType, PointType >::_outputMin = null [protected] |
IVector IG::Num::DistanceComparer< PointContainerType, PointType >::_outputMax = null [protected] |
IComparer<PointContainerType> IG::Num::DistanceComparer< PointContainerType, PointType >::_storedDistanceComparer [private] |
object IG::Num::DistanceComparer< PointContainerType, PointType >::Lock [get] |
This object's central lock object to be used by other object. Do not use this object for locking in class' methods, for this you should use InternalLock.
Implements IG::Lib::ILockable.
PointContainerType IG::Num::DistanceComparer< PointContainerType, PointType >::ReferencePoint [get, set] |
Reference point. Points are compared with respect to the distance to this point.
Implements IG::Num::IDistanceComparer< PointContainerType, PointType >.
DistanceDelegate<PointType> IG::Num::DistanceComparer< PointContainerType, PointType >::DistanceFunction [get, set, protected] |
Delegate that calculates distance between two vectors. If set to nul then default distance function (DefaultDistanceFunction) is used for distance calculation.
IVector IG::Num::DistanceComparer< PointContainerType, PointType >::LengthScales [get, set] |
Sets the vector of length scales that are used for calculation of distances. Property has protected setter.
Implements IG::Num::IDistanceComparer< PointContainerType, PointType >.
IVector IG::Num::DistanceComparer< PointContainerType, PointType >::Min [get, set] |
Sets the vector of minimal values for point coordinates. Needed for calculation of relative coordinate vector. Property has protected setter.
Implements IG::Num::IDistanceComparer< PointContainerType, PointType >.
IVector IG::Num::DistanceComparer< PointContainerType, PointType >::Max [get, set] |
Sets the vector of maximal values point coordinates. Needed for calculation of relative coordinate vector. Property has protected setter.
Implements IG::Num::IDistanceComparer< PointContainerType, PointType >.
IVector IG::Num::DistanceComparer< PointContainerType, PointType >::OutputLengthScales [get, set] |
Sets the vector of OUTPUT vector's length scales that are used for calculation of distances and relative coordinates. Property has protected setter.
This functionality is used only in those types of points that have input parameters and output values, such as approximation data points.
Implements IG::Num::IDistanceComparer< PointContainerType, PointType >.
IVector IG::Num::DistanceComparer< PointContainerType, PointType >::OutputMin [get, set] |
Sets the vector of minimal values for point OUTPUT values. Needed for calculation of relative coordinate vector. Property has protected setter.
This functionality is used only in those types of points that have input parameters and output values, such as approximation data points.
Implements IG::Num::IDistanceComparer< PointContainerType, PointType >.
IVector IG::Num::DistanceComparer< PointContainerType, PointType >::OutputMax [get, set] |
Sets the vector of maximal values point OUTPUT values. Needed for calculation of relative coordinate vector. Property has protected setter.
This functionality is used only in those types of points that have input parameters and output values, such as approximation data points.
Implements IG::Num::IDistanceComparer< PointContainerType, PointType >.
IComparer<PointContainerType> IG::Num::DistanceComparer< PointContainerType, PointType >::StoredDistanceComparer [get] |
Gets comparer that compares two point containers of type PointContainerType by the stored distance stored on those points.
Implements IG::Num::IDistanceComparer< PointContainerType, PointType >.