cMHN 1.1
C++ library for learning MHNs with pRC
Loading...
Searching...
No Matches
optimize.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef pRC_ALGORITHMS_OPTIMIZE_H
4#define pRC_ALGORITHMS_OPTIMIZE_H
5
10
11namespace pRC
12{
13 template<class Optimizer, class XX, class RX = RemoveReference<XX>,
14 class TX = typename RX::Type, class VX = typename TX::Value,
15 If<IsTensorish<RX>> = 0,
16 class RXE = RemoveConstReference<ResultOf<Eval, XX>>, class FF,
17 If<IsInvocable<FF, RXE const &, RXE &>> = 0,
18 If<IsFloat<ResultOf<FF, RXE const &, RXE &>>> = 0, class FC,
19 If<IsInvocable<FC, RXE &>> = 0, class VT = VX,
20 If<All<IsFloat<VX>, IsFloat<VT>>> = 0,
21 If<IsInvocable<Optimizer, XX, FF, FC, VT>> = 0>
22 static inline constexpr auto optimize(Optimizer &&optimizer, XX &&x,
24 VT const &tolerance = NumericLimits<VT>::tolerance())
25 {
28 }
29
30 template<class Optimizer, class XX, class RX = RemoveReference<XX>,
31 class TX = typename RX::Type, class VX = typename TX::Value,
32 If<IsTensorish<RX>> = 0,
33 class RXE = RemoveConstReference<ResultOf<Eval, XX>>, class FF,
34 If<IsInvocable<FF, RXE const &, RXE &>> = 0,
35 If<IsFloat<ResultOf<FF, RXE const &, RXE &>>> = 0, class VT = VX,
36 If<All<IsFloat<VX>, IsFloat<VT>>> = 0,
37 If<IsInvocable<Optimizer, XX, FF, void(RXE const), VT>> = 0>
38 static inline constexpr auto optimize(Optimizer &&optimizer, XX &&x,
39 FF &&function, VT const &tolerance = NumericLimits<VT>::tolerance())
40 {
41 return optimize(
42 forward<Optimizer>(optimizer), forward<XX>(x),
43 forward<FF>(function),
44 [](auto &&)
45 {
46 },
47 tolerance);
48 }
49
50 template<class Optimizer, class XX, class RX = RemoveReference<XX>,
51 class TX = typename RX::Type, class VX = typename TX::Value,
52 If<IsTensorish<RX>> = 0,
53 class RXE = RemoveConstReference<ResultOf<Eval, XX>>, class FF,
54 If<IsInvocable<FF, RXE const &, RXE &>> = 0,
55 If<IsFloat<ResultOf<FF, RXE const &, RXE &>>> = 0, class FC,
56 If<IsInvocable<FC, RXE &>> = 0, class VT = VX,
57 If<All<IsFloat<VX>, IsFloat<VT>>> = 0,
58 If<IsInvocable<Optimizer, XX, FF, FC, VT>> = 0>
59 static inline constexpr auto optimize(XX &&x, FF &&function, FC &&callback,
60 VT const &tolerance = NumericLimits<VT>::tolerance())
61 {
62 return optimize(Optimizer(), forward<XX>(x), forward<FF>(function),
63 forward<FC>(callback), tolerance);
64 }
65
66 template<class Optimizer, class XX, class RX = RemoveReference<XX>,
67 class TX = typename RX::Type, class VX = typename TX::Value,
68 If<IsTensorish<RX>> = 0,
69 class RXE = RemoveConstReference<ResultOf<Eval, XX>>, class FF,
70 If<IsInvocable<FF, RXE const &, RXE &>> = 0,
71 If<IsFloat<ResultOf<FF, RXE const &, RXE &>>> = 0, class VT = VX,
72 If<All<IsFloat<VX>, IsFloat<VT>>> = 0,
73 If<IsInvocable<Optimizer, XX, FF, void(RXE const), VT>> = 0>
74 static inline constexpr auto optimize(XX &&x, FF &&function,
75 VT const &tolerance = NumericLimits<VT>::tolerance())
76 {
77 return optimize(Optimizer(), forward<XX>(x), forward<FF>(function),
78 tolerance);
79 }
80}
81#endif // pRC_ALGORITHMS_OPTIMIZE_H
Definition cholesky.hpp:18
static constexpr auto optimize(Optimizer &&optimizer, XX &&x, FF &&function, FC &&callback, VT const &tolerance=NumericLimits< VT >::tolerance())
Definition optimize.hpp:22
static constexpr auto makeConstantSequence()
Definition sequence.hpp:402
Definition limits.hpp:13