Loading...
Searching...
No Matches
lossfunction.h
Go to the documentation of this file.
1#ifndef _BBM_LOSSFUNCTION_CONCEPT_H_
2#define _BBM_LOSSFUNCTION_CONCEPT_H_
3
4#include <utility>
5#include "concepts/macro.h"
6
7#include "bbm/config.h"
8
9/************************************************************************/
10/*! \file lossfunction.h
11
12 \brief loss function contract
13
14*************************************************************************/
15
16namespace bbm {
17 namespace concepts {
18
19 /********************************************************************/
20 /*! \brief loss function concept
21
22 Each loss function requires:
23 + concepts::has_config
24 + update(void) method that initializes the loss. This method should be called at the beginning of each optimization step()
25 + Value_t operator()(Mask=true) const method that returns the loss.
26 + The returned loss should support addition.
27 *********************************************************************/
28 template<typename LOSSFUNC>
29 concept lossfunction = requires(std::decay_t<LOSSFUNC>& func)
30 {
32 { func.update() };
33 { std::as_const(func)() } -> std::same_as<Value_t<LOSSFUNC>>;
34 { std::as_const(func)(std::declval<typename std::decay_t<Mask_t<LOSSFUNC>>>()) } -> std::same_as<Value_t<LOSSFUNC>>;
35 };
36
37 namespace archetype {
38 /******************************************************************/
39 /*! \brief lossfunction archetype for concept checking
40
41 \tparam CONF = config to check for. Default = archetype::congif
42 ******************************************************************/
43 template<typename CONF=config> requires concepts::config<CONF>
45 {
46 using Config = CONF;
47 void update(void);
48 Value_t<Config> operator()(Mask_t<Config> = true) const;
49 };
50 } // end archetype namespace
51
53
54 } // end concepts namespace
55} // end bbm namespace
56
57#endif /* _BBM_LOSSFUNCTION_CONCEPT_H_ */
All BBM methods are defined to operate on a variety of value types and spectrum types....
config concept
Definition: config.h:31
has_config
Definition: config.h:53
loss function concept
Definition: lossfunction.h:29
Macros for checking if a class meets a concept.
#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
lossfunction archetype for concept checking
Definition: lossfunction.h:45
Value_t< Config > operator()(Mask_t< Config >=true) const
CONF Config
Definition: lossfunction.h:46