Loading...
Searching...
No Matches
sampledlossfunction.h
Go to the documentation of this file.
1#ifndef _BBM_SAMPLEDLOSSFUNCTION_CONCEPT_H_
2#define _BBM_SAMPLEDLOSSFUNCTION_CONCEPT_H_
3
4#include <utility>
6
7/************************************************************************/
8/*! \file sampledlossfunction.h
9
10 \brief sampled loss function contract
11
12*************************************************************************/
13
14namespace bbm {
15 namespace concepts {
16
17 /********************************************************************/
18 /*! \brief sampled loss function concept
19
20 Each loss sampled function requires:
21 + concepts::lossfunction
22 + Size_t samples(void) const returns the number of samples.
23 + Value_t operator(Size_t index, Mask=true) const that returns the loss of the index-the sample
24 + The returned loss should support addition.
25 *********************************************************************/
26 template<typename LOSSFUNC>
27 concept sampledlossfunction = requires(LOSSFUNC func)
28 {
30
31 { std::as_const(func).samples() } -> std::same_as<Size_t<LOSSFUNC>>;
32
33 { std::as_const(func)(std::declval<Size_t<LOSSFUNC>>()) } -> std::same_as<Value_t<LOSSFUNC>>;
34 { std::as_const(func)(std::declval<Size_t<LOSSFUNC>>(), std::declval<Mask_t<LOSSFUNC>>()) } -> std::same_as<Value_t<LOSSFUNC>>;
36 };
37
38 /********************************************************************/
39 /*! \brief sampledlossfunction archetype for concept checking
40
41 \tparam CONF = config to check for. Default = archetype::config
42 *********************************************************************/
43 namespace archetype {
44 template<typename CONF=config> requires concepts::config<CONF>
46 {
47 using Config=CONF;
48 using lossfunction<CONF>::operator();
49 Size_t<Config> samples(void) const;
50 Value_t<Config> operator()(const Size_t<Config>&, Mask_t<Config>) const;
51 };
52
53 } // end archetype namespace
54
56
57 } // end concepts namespace
58} // end bbm namespace
59
60#endif /* _BBM_LOSSFUNCTION_CONCEPT_H_ */
config concept
Definition: config.h:31
Definition: util.h:52
loss function concept
Definition: lossfunction.h:29
sampled loss function concept
Definition: sampledlossfunction.h:27
loss function contract
#define BBM_CHECK_CONCEPT(CONCEPTNAME, CLASSNAME,...)
Check a class for a concept with bbm::concepts::archetypes in the namespace.
Definition: macro.h:35
Definition: aggregatebsdf.h:29
typename get_config< T >::Value Value_t
Definition: config.h:67
Definition: sampledlossfunction.h:46
Value_t< Config > operator()(const Size_t< Config > &, Mask_t< Config >) const
Size_t< Config > samples(void) const
CONF Config
Definition: sampledlossfunction.h:47