proxsuite
0.7.3
The Advanced Proximal Optimization Toolbox
Toggle main menu visibility
Loading...
Searching...
No Matches
common.hpp
Go to the documentation of this file.
1
//
2
// Copyright (c) 2022 INRIA
3
//
7
8
#ifndef PROXSUITE_HELPERS_COMMON_HPP
9
#define PROXSUITE_HELPERS_COMMON_HPP
10
11
#include "proxsuite/config.hpp"
12
#include <limits>
13
14
namespace
proxsuite
{
15
namespace
helpers
{
16
17
template
<
typename
Scalar>
18
struct
infinite_bound
19
{
20
static
Scalar
value
()
21
{
22
using namespace
std
;
23
return
sqrt(std::numeric_limits<Scalar>::max());
24
}
25
};
26
27
#define PROXSUITE_DEDUCE_RET(...) \
28
noexcept(noexcept(__VA_ARGS__)) \
29
->typename std::remove_const<decltype(__VA_ARGS__)>::type \
30
{ \
31
return __VA_ARGS__; \
32
} \
33
static_assert(true, ".")
34
36
template
<
typename
T,
typename
Scalar>
37
auto
38
at_most
(T
const
& expr,
const
Scalar value)
PROXSUITE_DEDUCE_RET
(
39
(expr.array() < value).select(expr, T::Constant(expr.rows(), value)));
40
42
template
<
typename
T,
typename
Scalar>
43
auto
44
at_least
(T
const
& expr,
const
Scalar value)
PROXSUITE_DEDUCE_RET
(
45
(expr.array() > value).select(expr, T::Constant(expr.rows(), value)));
46
48
template
<
typename
T>
49
auto
50
positive_part
(T
const
& expr)
51
PROXSUITE_DEDUCE_RET
((expr.array() > 0).select(expr, T::Zero(expr.rows())));
52
54
template
<
typename
T>
55
auto
56
negative_part
(T
const
& expr)
57
PROXSUITE_DEDUCE_RET
((expr.array() < 0).select(expr, T::Zero(expr.rows())));
58
61
template
<
typename
Condition,
typename
T,
typename
Scalar>
62
auto
63
select
(Condition
const
& condition, T
const
& expr,
const
Scalar value)
64
PROXSUITE_DEDUCE_RET
((condition).
select
(expr,
65
T::Constant(expr.rows(), value)));
66
67
}
// helpers
68
}
// proxsuite
69
70
#endif
// ifndef PROXSUITE_HELPERS_COMMON_HPP
PROXSUITE_DEDUCE_RET
#define PROXSUITE_DEDUCE_RET(...)
Definition
common.hpp:27
proxsuite::helpers
Definition
common.hpp:15
proxsuite::helpers::select
auto select(Condition const &condition, T const &expr, const Scalar value) PROXSUITE_DEDUCE_RET((condition).select(expr
Select the components of the expression if the condition is fullfiled. Otherwise, set the component t...
proxsuite::helpers::positive_part
auto positive_part(T const &expr) PROXSUITE_DEDUCE_RET((expr.array() > 0).select(expr
Returns the positive part of an expression.
proxsuite::helpers::at_least
auto at_least(T const &expr, const Scalar value) PROXSUITE_DEDUCE_RET((expr.array() > value).select(expr
Returns the part of the expression which is greater than value.
proxsuite::helpers::at_most
auto at_most(T const &expr, const Scalar value) PROXSUITE_DEDUCE_RET((expr.array()< value).select(expr
Returns the part of the expression which is lower than value.
proxsuite::helpers::negative_part
auto negative_part(T const &expr) PROXSUITE_DEDUCE_RET((expr.array()< 0).select(expr
Returns the negative part of an expression.
proxsuite
Definition
common.hpp:14
std
STL namespace.
proxsuite::helpers::infinite_bound
Definition
common.hpp:19
proxsuite::helpers::infinite_bound::value
static Scalar value()
Definition
common.hpp:20
include
proxsuite
helpers
common.hpp
Generated by
1.17.0