.. _program_listing_file__tmp_ws_src_proxsuite_include_proxsuite_helpers_common.hpp: Program Listing for File common.hpp =================================== |exhale_lsh| :ref:`Return to documentation for file ` (``/tmp/ws/src/proxsuite/include/proxsuite/helpers/common.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp // // Copyright (c) 2022 INRIA // #ifndef PROXSUITE_HELPERS_COMMON_HPP #define PROXSUITE_HELPERS_COMMON_HPP #include "proxsuite/config.hpp" #include namespace proxsuite { namespace helpers { template struct infinite_bound { static Scalar value() { using namespace std; return sqrt(std::numeric_limits::max()); } }; #define PROXSUITE_DEDUCE_RET(...) \ noexcept(noexcept(__VA_ARGS__)) \ ->typename std::remove_const::type \ { \ return __VA_ARGS__; \ } \ static_assert(true, ".") template auto at_most(T const& expr, const Scalar value) PROXSUITE_DEDUCE_RET( (expr.array() < value).select(expr, T::Constant(expr.rows(), value))); template auto at_least(T const& expr, const Scalar value) PROXSUITE_DEDUCE_RET( (expr.array() > value).select(expr, T::Constant(expr.rows(), value))); template auto positive_part(T const& expr) PROXSUITE_DEDUCE_RET((expr.array() > 0).select(expr, T::Zero(expr.rows()))); template auto negative_part(T const& expr) PROXSUITE_DEDUCE_RET((expr.array() < 0).select(expr, T::Zero(expr.rows()))); template auto select(Condition const& condition, T const& expr, const Scalar value) PROXSUITE_DEDUCE_RET((condition).select(expr, T::Constant(expr.rows(), value))); } // helpers } // proxsuite #endif // ifndef PROXSUITE_HELPERS_COMMON_HPP