Class SpatialWeight

Class Documentation

class SpatialWeight

A combined class of distance and weight. Instances of this class are usually constructed by providing pointers to CGwmDistance and CGwmWeight. In the construct function, instances of types CGwmDistance and CGwmWeight will be cloned. This class provide the method CGwmSpatialWeight::weightVector() to calculate spatial weight directly.

If the distance and weight are set by pointers, this class will take the control of them, and when destructing the pointers will be deleted. If the distance and weight are set by references, this class will clone them.

Public Functions

inline SpatialWeight()

Construct a new CGwmSpatialWeight object.

inline SpatialWeight(const Weight *weight, const Distance *distance)

Construct a new CGwmSpatialWeight object.

Parameters:
  • weight – Pointer to a weight configuration.

  • distance – Pointer to distance configuration.

inline SpatialWeight(const Weight &weight, const Distance &distance)

Construct a new CGwmSpatialWeight object.

Parameters:
  • weight – Reference to a weight configuration.

  • distance – Reference to distance configuration.

inline SpatialWeight(const SpatialWeight &spatialWeight)

Copy construct a new CGwmSpatialWeight object.

Parameters:

spatialWeight – Reference to the object to copy from.

inline SpatialWeight(SpatialWeight &&other)

Move construct a new CGwmSpatialWeight object.

Parameters:

other – Reference to the object to move from.

virtual ~SpatialWeight()

Destroy the CGwmSpatialWeight object.

inline Weight *weight() const

Get the pointer to CGwmSpatialWeight::mWeight .

Returns:

Pointer to CGwmSpatialWeight::mWeight .

inline void setWeight(Weight *weight)

Set the pointer to CGwmSpatialWeight::mWeight object.

Parameters:

weight – Pointer to CGwmWeight instance. Control of this pointer will be taken, and it will be deleted when destructing.

inline void setWeight(Weight &weight)

Set the pointer to CGwmSpatialWeight::mWeight object.

Parameters:

weight – Reference to CGwmWeight instance. This object will be cloned.

inline void setWeight(Weight &&weight)

Set the pointer to CGwmSpatialWeight::mWeight object.

Parameters:

weight – Reference to CGwmWeight instance. This object will be cloned.

template<typename T>
inline T *weight() const

Get the pointer to CGwmSpatialWeight::mWeight and cast it to required type.

Template Parameters:

T – Type of return value. Only CGwmBandwidthWeight is allowed.

Returns:

Casted pointer to CGwmSpatialWeight::mWeight.

inline Distance *distance() const

Get the pointer to CGwmSpatialWeight::mDistance.

Returns:

Pointer to CGwmSpatialWeight::mDistance.

inline void setDistance(Distance *distance)

Set the pointer to CGwmSpatialWeight::mDistance object.

Parameters:

distance – Pointer to CGwmDistance instance. Control of this pointer will be taken, and it will be deleted when destructing.

inline void setDistance(Distance &distance)

Set the pointer to CGwmSpatialWeight::mDistance object.

Parameters:

distance – Reference to CGwmDistance instance. This object will be cloned.

inline void setDistance(Distance &&distance)

Set the pointer to CGwmSpatialWeight::mDistance object.

Parameters:

distance – Reference to CGwmDistance instance. This object will be cloned.

template<typename T>
inline T *distance() const

Get the pointer to CGwmSpatialWeight::mDistance and cast it to required type.

Template Parameters:

T – Type of return value. Only CGwmCRSDistance and CGwmMinkwoskiDistance is allowed.

Returns:

Casted pointer to CGwmSpatialWeight::mDistance.

SpatialWeight &operator=(const SpatialWeight &spatialWeight)

Override operator = for this class. This function will first delete the current CGwmSpatialWeight::mWeight and CGwmSpatialWeight::mDistance, and then clone CGwmWeight and CGwmDistance instances according pointers of the right value.

Parameters:

spatialWeight – Reference to the right value.

Returns:

Reference of this object.

SpatialWeight &operator=(SpatialWeight &&spatialWeight)

Override operator = for this class. This function will first delete the current CGwmSpatialWeight::mWeight and CGwmSpatialWeight::mDistance, and then clone CGwmWeight and CGwmDistance instances according pointers of the right value.

Parameters:

spatialWeight – Right value reference to the right value.

Returns:

Reference of this object.

inline virtual arma::vec weightVector(arma::uword focus) const

Calculate the spatial weight vector from focused sample to other samples (including the focused sample itself).

Parameters:

focus – Index of current sample.

Returns:

vec The spatial weight vector from focused sample to other samples.

virtual bool isValid()

Get whether this object is valid in geting weight vector.

Returns:

true if this object is valid.

Returns:

false if this object is invalid.

template<>
inline BandwidthWeight *weight() const

Get the pointer to CGwmSpatialWeight::mWeight and cast it to CGwmBandwidthWeight type.

Returns:

Casted pointer to CGwmSpatialWeight::mWeight.

template<>
inline CRSDistance *distance() const

Get the pointer to CGwmSpatialWeight::mDistance and cast it to CGwmCRSDistance type.

Returns:

Casted pointer to CGwmSpatialWeight::mDistance.

template<>
inline CRSSTDistance *distance() const

Get the pointer to CGwmSpatialWeight::mDistance and cast it to CGwmCRSSTDistance type.

Returns:

Casted pointer to CGwmSpatialWeight::mDistance.

template<>
inline MinkwoskiDistance *distance() const

Get the pointer to CGwmSpatialWeight::mDistance and cast it to CGwmMinkwoskiDistance type.

Returns:

Casted pointer to CGwmSpatialWeight::mDistance.

template<>
inline DMatDistance *distance() const

Get the pointer to CGwmSpatialWeight::mDistance and cast it to CGwmDMatDistance type.

Returns:

Casted pointer to CGwmSpatialWeight::mDistance.

template<>
inline OneDimDistance *distance() const

Get the pointer to CGwmSpatialWeight::mDistance and cast it to CGwmOneDimDistance type.

Returns:

Casted pointer to CGwmSpatialWeight::mDistance.