WeightedLowess
A C++ library for LOWESS with various weighting schemes
Loading...
Searching...
No Matches
Public Member Functions | List of all members
WeightedLowess::SortBy Class Reference

Utility class for sorting on a covariate. More...

#include <SortBy.hpp>

Public Member Functions

template<typename Sortable_ >
 SortBy (size_t num_points, const Sortable_ *x)
 
 SortBy ()=default
 
template<typename Sortable_ >
void set (size_t num_points, const Sortable_ *x)
 
template<typename Data_ , typename Used_ >
void permute (Data_ *data, Used_ *work) const
 
template<typename Data_ , typename Used_ >
void permute (std::initializer_list< Data_ > data, Used_ *work) const
 
template<typename DataPointers_ , typename Used_ >
void permute (DataPointers_ data, Used_ *work) const
 
template<typename Data_ , typename Used_ >
void permute (Data_ *data, std::vector< Used_ > &work) const
 
template<typename Data_ , typename Used_ >
void permute (std::initializer_list< Data_ > data, std::vector< Used_ > &work) const
 
template<typename DataPointers_ , typename Used_ >
void permute (DataPointers_ data, std::vector< Used_ > &work) const
 
template<typename Data_ , typename Used_ >
void unpermute (Data_ *data, Used_ *work) const
 
template<typename Data_ , typename Used_ >
void unpermute (std::initializer_list< Data_ * > data, Used_ *work) const
 
template<typename DataPointers_ , typename Used_ >
void unpermute (DataPointers_ data, Used_ *work) const
 
template<typename Data_ , typename Used_ >
void unpermute (Data_ *data, std::vector< Used_ > &work) const
 
template<typename Data_ , typename Used_ >
void unpermute (std::initializer_list< Data_ * > data, std::vector< Used_ > &work) const
 
template<typename DataPointers_ , typename Used_ >
void unpermute (DataPointers_ data, std::vector< Used_ > &work) const
 

Detailed Description

Utility class for sorting on a covariate.

This is typically used to ensure that x-values are sorted prior to calling compute(). The idea is to create a permutation vector from the x-values to sort them in ascending order; use permute() to apply that permutation to the various arrays of x-values, y-values and weights (if applicable); calculate the fitted values from the permuted arrays with compute(), now that the x-values are sorted; and then use unpermute() on the results of the fit, to obtain fitted values for the points in their original (pre-sort) order.

Constructor & Destructor Documentation

◆ SortBy() [1/2]

template<typename Sortable_ >
WeightedLowess::SortBy::SortBy ( size_t  num_points,
const Sortable_ *  x 
)
inline
Template Parameters
Sortable_Sortable type.
Parameters
num_pointsNumber of points.
[in]xPointer to an array of sortable values, typically x-values for the dataset.

◆ SortBy() [2/2]

WeightedLowess::SortBy::SortBy ( )
default

Default constructor. The object should not be used until set() is called.

Member Function Documentation

◆ permute() [1/6]

template<typename Data_ , typename Used_ >
void WeightedLowess::SortBy::permute ( Data_ *  data,
std::vector< Used_ > &  work 
) const
inline
Template Parameters
Data_Any data type.
Used_Boolean value for the workspace.
Parameters
[in,out]dataPointer to an array of length num_points to be permuted in-place, in the same manner that x (from the constructor) would be permuted for sorting.
workWorkspace. This can be empty and will be recycled across permute() and unpermute() calls.

◆ permute() [2/6]

template<typename Data_ , typename Used_ >
void WeightedLowess::SortBy::permute ( Data_ *  data,
Used_ *  work 
) const
inline
Template Parameters
Data_Any data type.
Used_Boolean value for the workspace.
Parameters
[in,out]dataPointer to an array of length num_points to be permuted in-place, in the same manner that x (from the constructor) would be permuted for sorting.
[in]workPointer to an array of length num_points, to use as the workspace. This can recycled across permute() and unpermute() calls.

◆ permute() [3/6]

template<typename DataPointers_ , typename Used_ >
void WeightedLowess::SortBy::permute ( DataPointers_  data,
std::vector< Used_ > &  work 
) const
inline
Template Parameters
DataPointers_Iterable container of pointers.
Used_Boolean value for the workspace.
Parameters
[in,out]dataOne or more pointers to arrays of length num_points to be permuted in-place, in the same manner that x (from the constructor) would be permuted for sorting.
workWorkspace. This can be empty and will be recycled across permute() and unpermute() calls.

◆ permute() [4/6]

template<typename DataPointers_ , typename Used_ >
void WeightedLowess::SortBy::permute ( DataPointers_  data,
Used_ *  work 
) const
inline
Template Parameters
DataPointers_Iterable container of pointers.
Used_Boolean value for the workspace.
Parameters
[in,out]dataOne or more pointers to arrays of length num_points to be permuted in-place, in the same manner that x (from the constructor) would be permuted for sorting.
[in]workPointer to an array of length num_points, to use as the workspace. This can recycled across permute() and unpermute() calls.

◆ permute() [5/6]

template<typename Data_ , typename Used_ >
void WeightedLowess::SortBy::permute ( std::initializer_list< Data_ >  data,
std::vector< Used_ > &  work 
) const
inline
Template Parameters
Data_Any data type.
Used_Boolean value for the workspace.
Parameters
[in,out]dataOne or more pointers to arrays of length num_points to be permuted in-place, in the same manner that x (from the constructor) would be permuted for sorting.
workWorkspace. This can be empty and will be recycled across permute() and unpermute() calls.

◆ permute() [6/6]

template<typename Data_ , typename Used_ >
void WeightedLowess::SortBy::permute ( std::initializer_list< Data_ >  data,
Used_ *  work 
) const
inline
Template Parameters
Data_Any data type.
Used_Boolean value for the workspace.
Parameters
[in,out]dataOne or more pointers to arrays of length num_points to be permuted in-place, in the same manner that x (from the constructor) would be permuted for sorting.
[in]workPointer to an array of length num_points, to use as the workspace. This can recycled across permute() and unpermute() calls.

◆ set()

template<typename Sortable_ >
void WeightedLowess::SortBy::set ( size_t  num_points,
const Sortable_ *  x 
)
inline
Template Parameters
Sortable_Sortable type.
Parameters
num_pointsNumber of points.
[in]xPointer to an array of sortable values, typically x-values for the dataset.

◆ unpermute() [1/6]

template<typename Data_ , typename Used_ >
void WeightedLowess::SortBy::unpermute ( Data_ *  data,
std::vector< Used_ > &  work 
) const
inline
Template Parameters
Data_Any data type.
Used_Boolean type for the workspace.
Parameters
[in,out]dataPointer to an array of length num_points to be permuted in-place to reverse the effect of permute().
workWorkspace. This can be empty and will be recycled across permute() and unpermute() calls.

◆ unpermute() [2/6]

template<typename Data_ , typename Used_ >
void WeightedLowess::SortBy::unpermute ( Data_ *  data,
Used_ *  work 
) const
inline
Template Parameters
Data_Any data type.
Used_Boolean type for the workspace.
Parameters
[in,out]dataPointer to an array of length num_points to be permuted in-place to reverse the effect of permute().
[in]workPointer to an array of length num_points. This can be recycled across permute() and unpermute() calls.

◆ unpermute() [3/6]

template<typename DataPointers_ , typename Used_ >
void WeightedLowess::SortBy::unpermute ( DataPointers_  data,
std::vector< Used_ > &  work 
) const
inline
Template Parameters
DataPointers_Iterable container of pointers.
Used_Boolean type for the workspace.
Parameters
[in,out]dataOne or more pointers to arrays of length num_points to be permuted in-place to reverse the effect of permute().
workWorkspace. This can be empty and will be recycled across permute() and unpermute() calls.

◆ unpermute() [4/6]

template<typename DataPointers_ , typename Used_ >
void WeightedLowess::SortBy::unpermute ( DataPointers_  data,
Used_ *  work 
) const
inline
Template Parameters
DataPointers_Iterable container of pointers.
Used_Boolean type for the workspace.
Parameters
[in,out]dataOne or more pointers to arrays of length num_points to be permuted in-place to reverse the effect of permute().
[in]workPointer to an array of length num_points. This can be recycled across permute() and unpermute() calls.

◆ unpermute() [5/6]

template<typename Data_ , typename Used_ >
void WeightedLowess::SortBy::unpermute ( std::initializer_list< Data_ * >  data,
std::vector< Used_ > &  work 
) const
inline
Template Parameters
Data_Any data type.
Used_Boolean type for the workspace.
Parameters
[in,out]dataOne or more pointers to arrays of length num_points to be permuted in-place to reverse the effect of permute().
workWorkspace. This can be empty and will be recycled across permute() and unpermute() calls.

◆ unpermute() [6/6]

template<typename Data_ , typename Used_ >
void WeightedLowess::SortBy::unpermute ( std::initializer_list< Data_ * >  data,
Used_ *  work 
) const
inline
Template Parameters
Data_Any data type.
Used_Boolean type for the workspace.
Parameters
[in,out]dataOne or more pointers to arrays of length num_points to be permuted in-place to reverse the effect of permute().
[in]workPointer to an array of length num_points. This can be recycled across permute() and unpermute() calls.

The documentation for this class was generated from the following file: