/usr/include/sopt/proximal_expression.h is in libsopt-dev 2.0.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | #ifndef SOPT_PROXIMAL_EXPRESSION_H
#define SOPT_PROXIMAL_EXPRESSION_H
#include "sopt/config.h"
#include <type_traits>
#include <Eigen/Core>
#include "sopt/maths.h"
namespace sopt {
//! Holds some standard proximals
namespace proximal {
namespace details {
//! \brief Expression referencing a lazy proximal function call
//! \details It helps transform the call ``proximal(out, gamma, input)``
//! to ``out = proximal(gamma, input)`` without incurring copy or allocation overhead if ``out``
//! already exists.
template <class FUNCTION, class DERIVED>
class DelayedProximalFunction
: public Eigen::ReturnByValue<DelayedProximalFunction<FUNCTION, DERIVED>> {
public:
typedef typename DERIVED::PlainObject PlainObject;
typedef typename DERIVED::Index Index;
typedef typename real_type<typename DERIVED::Scalar>::type Real;
DelayedProximalFunction(FUNCTION const &func, Real const &gamma, DERIVED const &x)
: func(func), gamma(gamma), x(x) {}
DelayedProximalFunction(DelayedProximalFunction const &c)
: func(c.func), gamma(c.gamma), x(c.x) {}
DelayedProximalFunction(DelayedProximalFunction &&c)
: func(std::move(c.func)), gamma(c.gamma), x(c.x) {}
template <class DESTINATION> void evalTo(DESTINATION &destination) const {
destination.resizeLike(x);
func(destination, gamma, x);
}
Index rows() const { return x.rows(); }
Index cols() const { return x.cols(); }
private:
FUNCTION const func;
Real const gamma;
DERIVED const &x;
};
//! \brief Expression referencing a lazy function call to envelope proximal
//! \details It helps transform the call ``proximal(out, input)``
//! to ``out = proximal(input)`` without incurring copy or allocation overhead if ``out``
//! already exists.
template <class FUNCTION, class DERIVED>
class DelayedProximalEnveloppeFunction
: public Eigen::ReturnByValue<DelayedProximalEnveloppeFunction<FUNCTION, DERIVED>> {
public:
typedef typename DERIVED::PlainObject PlainObject;
typedef typename DERIVED::Index Index;
typedef typename real_type<typename DERIVED::Scalar>::type Real;
DelayedProximalEnveloppeFunction(FUNCTION const &func, DERIVED const &x) : func(func), x(x) {}
DelayedProximalEnveloppeFunction(DelayedProximalEnveloppeFunction const &c)
: func(c.func), x(c.x) {}
DelayedProximalEnveloppeFunction(DelayedProximalEnveloppeFunction &&c)
: func(std::move(c.func)), x(c.x) {}
template <class DESTINATION> void evalTo(DESTINATION &destination) const {
destination.resizeLike(x);
func(destination, x);
}
Index rows() const { return x.rows(); }
Index cols() const { return x.cols(); }
private:
FUNCTION const func;
DERIVED const &x;
};
} /* details */
//! Eigen expression from proximal functions
template <class FUNC, class T0>
using ProximalExpression = details::DelayedProximalFunction<FUNC, Eigen::MatrixBase<T0>>;
//! Eigen expression from proximal enveloppe functions
template <class FUNC, class T0>
using EnveloppeExpression = details::DelayedProximalEnveloppeFunction<FUNC, Eigen::MatrixBase<T0>>;
}
} /* sopt::proximal */
namespace Eigen {
namespace internal {
template <class FUNCTION, class VECTOR>
struct traits<sopt::proximal::details::DelayedProximalFunction<FUNCTION, VECTOR>> {
typedef typename VECTOR::PlainObject ReturnType;
};
template <class FUNCTION, class VECTOR>
struct traits<sopt::proximal::details::DelayedProximalEnveloppeFunction<FUNCTION, VECTOR>> {
typedef typename VECTOR::PlainObject ReturnType;
};
}
}
#endif
|