SIRIUS 7.5.0
Electronic structure library and applications
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
sirius::mixer::Mixer< FUNCS > Class Template Referenceabstract

Abstract mixer for variadic number of Function objects, which are described by FunctionProperties. More...

#include <mixer.hpp>

Public Member Functions

 Mixer (std::size_t max_history)
 Construct a mixer. Functions have to initialized individually. More...
 
template<std::size_t FUNC_INDEX, typename... ARGS>
void initialize_function (const FunctionProperties< typename std::tuple_element< FUNC_INDEX, std::tuple< FUNCS... > >::type > &function_prop, const typename std::tuple_element< FUNC_INDEX, std::tuple< FUNCS... > >::type &init_value, ARGS &&... args)
 
template<std::size_t FUNC_INDEX>
void set_input (const typename std::tuple_element< FUNC_INDEX, std::tuple< FUNCS... > >::type &input)
 Set input for next mixing step. More...
 
template<std::size_t FUNC_INDEX>
void get_output (typename std::tuple_element< FUNC_INDEX, std::tuple< FUNCS... > >::type &output)
 Access last generated output. Mixing must have been performed at least once. More...
 
double mix (double rms_min__)
 Mix input and stored history. Returns the root mean square error computed by inner products of residuals. More...
 

Static Public Attributes

static constexpr std::size_t number_of_functions = sizeof...(FUNCS)
 

Protected Member Functions

virtual void mix_impl ()=0
 
void update_residual ()
 
void update_rms ()
 
std::size_t idx_hist (std::size_t step) const
 
template<bool normalize>
double inner_product (const std::tuple< std::unique_ptr< FUNCS >... > &x, const std::tuple< std::unique_ptr< FUNCS >... > &y)
 
void scale (double alpha, std::tuple< std::unique_ptr< FUNCS >... > &x)
 
void copy (const std::tuple< std::unique_ptr< FUNCS >... > &x, std::tuple< std::unique_ptr< FUNCS >... > &y)
 
void axpy (double alpha, const std::tuple< std::unique_ptr< FUNCS >... > &x, std::tuple< std::unique_ptr< FUNCS >... > &y)
 
void rotate (double c, double s, std::tuple< std::unique_ptr< FUNCS >... > &x, std::tuple< std::unique_ptr< FUNCS >... > &y)
 

Protected Attributes

std::size_t step_
 
std::size_t max_history_
 
std::vector< double > rmse_history_
 
std::tuple< FunctionProperties< FUNCS >... > functions_
 
std::tuple< std::unique_ptr< FUNCS >... > input_
 
std::vector< std::tuple< std::unique_ptr< FUNCS >... > > output_history_
 
std::vector< std::tuple< std::unique_ptr< FUNCS >... > > residual_history_
 

Detailed Description

template<typename... FUNCS>
class sirius::mixer::Mixer< FUNCS >

Abstract mixer for variadic number of Function objects, which are described by FunctionProperties.

Can mix variadic number of functions objects, for which operations are defined in FunctionProperties. Only functions, which are explicitly initialized, are mixed.

Definition at line 278 of file mixer.hpp.

Constructor & Destructor Documentation

◆ Mixer()

template<typename... FUNCS>
sirius::mixer::Mixer< FUNCS >::Mixer ( std::size_t  max_history)
inline

Construct a mixer. Functions have to initialized individually.

Parameters
[in]max_historyMaximum number of steps stored, which contribute to the mixing.
[in]commmCommunicator used for exchaning mixing contributions.

Definition at line 289 of file mixer.hpp.

Member Function Documentation

◆ initialize_function()

template<typename... FUNCS>
template<std::size_t FUNC_INDEX, typename... ARGS>
void sirius::mixer::Mixer< FUNCS >::initialize_function ( const FunctionProperties< typename std::tuple_element< FUNC_INDEX, std::tuple< FUNCS... > >::type > &  function_prop,
const typename std::tuple_element< FUNC_INDEX, std::tuple< FUNCS... > >::type &  init_value,
ARGS &&...  args 
)
inline

Initialize function at given index with given value. A new function object is created with "args" passed to the constructor. Only initialized functions are mixed.

Parameters
[in]function_propFunction properties, which describe operations.
[in]init_valueInitial function value for input / output.
[in]argsArguments, which are passed to the constructor of function placeholder objects.

Definition at line 307 of file mixer.hpp.

◆ set_input()

template<typename... FUNCS>
template<std::size_t FUNC_INDEX>
void sirius::mixer::Mixer< FUNCS >::set_input ( const typename std::tuple_element< FUNC_INDEX, std::tuple< FUNCS... > >::type &  input)
inline

Set input for next mixing step.

Parameters
[in]inputInput functions, for which a copy operation is invoked.

Definition at line 340 of file mixer.hpp.

◆ get_output()

template<typename... FUNCS>
template<std::size_t FUNC_INDEX>
void sirius::mixer::Mixer< FUNCS >::get_output ( typename std::tuple_element< FUNC_INDEX, std::tuple< FUNCS... > >::type &  output)
inline

Access last generated output. Mixing must have been performed at least once.

Parameters
[out]outputOutput function, into which the mixer output is copied.

Definition at line 353 of file mixer.hpp.

◆ mix()

template<typename... FUNCS>
double sirius::mixer::Mixer< FUNCS >::mix ( double  rms_min__)
inline

Mix input and stored history. Returns the root mean square error computed by inner products of residuals.

Parameters
[in]rms_minMinimum root mean square error. Mixing is only performed, if current RMS is above this threshold.

Definition at line 366 of file mixer.hpp.

◆ update_residual()

template<typename... FUNCS>
void sirius::mixer::Mixer< FUNCS >::update_residual ( )
inlineprotected

Definition at line 387 of file mixer.hpp.

◆ update_rms()

template<typename... FUNCS>
void sirius::mixer::Mixer< FUNCS >::update_rms ( )
inlineprotected

Definition at line 394 of file mixer.hpp.

◆ idx_hist()

template<typename... FUNCS>
std::size_t sirius::mixer::Mixer< FUNCS >::idx_hist ( std::size_t  step) const
inlineprotected

Definition at line 405 of file mixer.hpp.

◆ inner_product()

template<typename... FUNCS>
template<bool normalize>
double sirius::mixer::Mixer< FUNCS >::inner_product ( const std::tuple< std::unique_ptr< FUNCS >... > &  x,
const std::tuple< std::unique_ptr< FUNCS >... > &  y 
)
inlineprotected

Definition at line 411 of file mixer.hpp.

◆ scale()

template<typename... FUNCS>
void sirius::mixer::Mixer< FUNCS >::scale ( double  alpha,
std::tuple< std::unique_ptr< FUNCS >... > &  x 
)
inlineprotected

Definition at line 417 of file mixer.hpp.

◆ copy()

template<typename... FUNCS>
void sirius::mixer::Mixer< FUNCS >::copy ( const std::tuple< std::unique_ptr< FUNCS >... > &  x,
std::tuple< std::unique_ptr< FUNCS >... > &  y 
)
inlineprotected

Definition at line 422 of file mixer.hpp.

◆ axpy()

template<typename... FUNCS>
void sirius::mixer::Mixer< FUNCS >::axpy ( double  alpha,
const std::tuple< std::unique_ptr< FUNCS >... > &  x,
std::tuple< std::unique_ptr< FUNCS >... > &  y 
)
inlineprotected

Definition at line 427 of file mixer.hpp.

◆ rotate()

template<typename... FUNCS>
void sirius::mixer::Mixer< FUNCS >::rotate ( double  c,
double  s,
std::tuple< std::unique_ptr< FUNCS >... > &  x,
std::tuple< std::unique_ptr< FUNCS >... > &  y 
)
inlineprotected

Definition at line 432 of file mixer.hpp.

Member Data Documentation

◆ number_of_functions

template<typename... FUNCS>
constexpr std::size_t sirius::mixer::Mixer< FUNCS >::number_of_functions = sizeof...(FUNCS)
staticconstexpr

Definition at line 283 of file mixer.hpp.

◆ step_

template<typename... FUNCS>
std::size_t sirius::mixer::Mixer< FUNCS >::step_
protected

Definition at line 438 of file mixer.hpp.

◆ max_history_

template<typename... FUNCS>
std::size_t sirius::mixer::Mixer< FUNCS >::max_history_
protected

Definition at line 441 of file mixer.hpp.

◆ rmse_history_

template<typename... FUNCS>
std::vector<double> sirius::mixer::Mixer< FUNCS >::rmse_history_
protected

Definition at line 444 of file mixer.hpp.

◆ functions_

template<typename... FUNCS>
std::tuple<FunctionProperties<FUNCS>...> sirius::mixer::Mixer< FUNCS >::functions_
protected

Definition at line 447 of file mixer.hpp.

◆ input_

template<typename... FUNCS>
std::tuple<std::unique_ptr<FUNCS>...> sirius::mixer::Mixer< FUNCS >::input_
protected

Definition at line 450 of file mixer.hpp.

◆ output_history_

template<typename... FUNCS>
std::vector<std::tuple<std::unique_ptr<FUNCS>...> > sirius::mixer::Mixer< FUNCS >::output_history_
protected

Definition at line 453 of file mixer.hpp.

◆ residual_history_

template<typename... FUNCS>
std::vector<std::tuple<std::unique_ptr<FUNCS>...> > sirius::mixer::Mixer< FUNCS >::residual_history_
protected

Definition at line 456 of file mixer.hpp.


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