-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #432 from bluescarni/pr/rel_bool_ops
Relational/logical operations
- Loading branch information
Showing
21 changed files
with
2,960 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
// Copyright 2020, 2021, 2022, 2023, 2024 Francesco Biscani ([email protected]), Dario Izzo ([email protected]) | ||
// | ||
// This file is part of the heyoka library. | ||
// | ||
// This Source Code Form is subject to the terms of the Mozilla | ||
// Public License v. 2.0. If a copy of the MPL was not distributed | ||
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
#ifndef HEYOKA_MATH_LOGICAL_HPP | ||
#define HEYOKA_MATH_LOGICAL_HPP | ||
|
||
#include <cstdint> | ||
#include <vector> | ||
|
||
#include <heyoka/config.hpp> | ||
#include <heyoka/detail/fwd_decl.hpp> | ||
#include <heyoka/detail/llvm_fwd.hpp> | ||
#include <heyoka/detail/visibility.hpp> | ||
#include <heyoka/func.hpp> | ||
#include <heyoka/s11n.hpp> | ||
|
||
HEYOKA_BEGIN_NAMESPACE | ||
|
||
namespace detail | ||
{ | ||
|
||
class HEYOKA_DLL_PUBLIC logical_and_impl : public func_base | ||
{ | ||
friend class boost::serialization::access; | ||
template <typename Archive> | ||
void serialize(Archive &ar, unsigned) | ||
{ | ||
ar &boost::serialization::base_object<func_base>(*this); | ||
} | ||
|
||
public: | ||
logical_and_impl(); | ||
explicit logical_and_impl(std::vector<expression>); | ||
|
||
[[nodiscard]] std::vector<expression> gradient() const; | ||
|
||
[[nodiscard]] llvm::Value *llvm_eval(llvm_state &, llvm::Type *, const std::vector<llvm::Value *> &, llvm::Value *, | ||
llvm::Value *, llvm::Value *, std::uint32_t, bool) const; | ||
|
||
[[nodiscard]] llvm::Function *llvm_c_eval_func(llvm_state &, llvm::Type *, std::uint32_t, bool) const; | ||
|
||
[[nodiscard]] llvm::Value *taylor_diff(llvm_state &, llvm::Type *, const std::vector<std::uint32_t> &, | ||
const std::vector<llvm::Value *> &, llvm::Value *, llvm::Value *, | ||
std::uint32_t, std::uint32_t, std::uint32_t, std::uint32_t, bool) const; | ||
|
||
[[nodiscard]] llvm::Function *taylor_c_diff_func(llvm_state &, llvm::Type *, std::uint32_t, std::uint32_t, | ||
bool) const; | ||
}; | ||
|
||
class HEYOKA_DLL_PUBLIC logical_or_impl : public func_base | ||
{ | ||
friend class boost::serialization::access; | ||
template <typename Archive> | ||
void serialize(Archive &ar, unsigned) | ||
{ | ||
ar &boost::serialization::base_object<func_base>(*this); | ||
} | ||
|
||
public: | ||
logical_or_impl(); | ||
explicit logical_or_impl(std::vector<expression>); | ||
|
||
[[nodiscard]] std::vector<expression> gradient() const; | ||
|
||
[[nodiscard]] llvm::Value *llvm_eval(llvm_state &, llvm::Type *, const std::vector<llvm::Value *> &, llvm::Value *, | ||
llvm::Value *, llvm::Value *, std::uint32_t, bool) const; | ||
|
||
[[nodiscard]] llvm::Function *llvm_c_eval_func(llvm_state &, llvm::Type *, std::uint32_t, bool) const; | ||
|
||
[[nodiscard]] llvm::Value *taylor_diff(llvm_state &, llvm::Type *, const std::vector<std::uint32_t> &, | ||
const std::vector<llvm::Value *> &, llvm::Value *, llvm::Value *, | ||
std::uint32_t, std::uint32_t, std::uint32_t, std::uint32_t, bool) const; | ||
|
||
[[nodiscard]] llvm::Function *taylor_c_diff_func(llvm_state &, llvm::Type *, std::uint32_t, std::uint32_t, | ||
bool) const; | ||
}; | ||
|
||
} // namespace detail | ||
|
||
HEYOKA_DLL_PUBLIC expression logical_and(std::vector<expression>); | ||
HEYOKA_DLL_PUBLIC expression logical_or(std::vector<expression>); | ||
|
||
HEYOKA_END_NAMESPACE | ||
|
||
HEYOKA_S11N_FUNC_EXPORT_KEY(heyoka::detail::logical_and_impl) | ||
HEYOKA_S11N_FUNC_EXPORT_KEY(heyoka::detail::logical_or_impl) | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
// Copyright 2020, 2021, 2022, 2023, 2024 Francesco Biscani ([email protected]), Dario Izzo ([email protected]) | ||
// | ||
// This file is part of the heyoka library. | ||
// | ||
// This Source Code Form is subject to the terms of the Mozilla | ||
// Public License v. 2.0. If a copy of the MPL was not distributed | ||
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
#ifndef HEYOKA_MATH_RELATIONAL_HPP | ||
#define HEYOKA_MATH_RELATIONAL_HPP | ||
|
||
#include <heyoka/config.hpp> | ||
|
||
#include <cstdint> | ||
#include <sstream> | ||
#include <vector> | ||
|
||
#if defined(HEYOKA_HAVE_REAL128) | ||
|
||
#include <mp++/real128.hpp> | ||
|
||
#endif | ||
|
||
#if defined(HEYOKA_HAVE_REAL) | ||
|
||
#include <mp++/real.hpp> | ||
|
||
#endif | ||
|
||
#include <heyoka/detail/fwd_decl.hpp> | ||
#include <heyoka/detail/llvm_fwd.hpp> | ||
#include <heyoka/detail/visibility.hpp> | ||
#include <heyoka/func.hpp> | ||
#include <heyoka/s11n.hpp> | ||
|
||
HEYOKA_BEGIN_NAMESPACE | ||
|
||
namespace detail | ||
{ | ||
|
||
enum class rel_op { eq, neq, lt, gt, lte, gte }; | ||
|
||
class HEYOKA_DLL_PUBLIC rel_impl : public func_base | ||
{ | ||
rel_op m_op = rel_op::eq; | ||
|
||
friend class boost::serialization::access; | ||
template <typename Archive> | ||
void serialize(Archive &ar, unsigned) | ||
{ | ||
ar &boost::serialization::base_object<func_base>(*this); | ||
ar & m_op; | ||
} | ||
|
||
public: | ||
rel_impl(); | ||
explicit rel_impl(rel_op, expression, expression); | ||
|
||
[[nodiscard]] rel_op get_op() const noexcept; | ||
|
||
void to_stream(std::ostringstream &) const; | ||
|
||
[[nodiscard]] std::vector<expression> gradient() const; | ||
|
||
[[nodiscard]] llvm::Value *llvm_eval(llvm_state &, llvm::Type *, const std::vector<llvm::Value *> &, llvm::Value *, | ||
llvm::Value *, llvm::Value *, std::uint32_t, bool) const; | ||
|
||
[[nodiscard]] llvm::Function *llvm_c_eval_func(llvm_state &, llvm::Type *, std::uint32_t, bool) const; | ||
|
||
[[nodiscard]] llvm::Value *taylor_diff(llvm_state &, llvm::Type *, const std::vector<std::uint32_t> &, | ||
const std::vector<llvm::Value *> &, llvm::Value *, llvm::Value *, | ||
std::uint32_t, std::uint32_t, std::uint32_t, std::uint32_t, bool) const; | ||
|
||
[[nodiscard]] llvm::Function *taylor_c_diff_func(llvm_state &, llvm::Type *, std::uint32_t, std::uint32_t, | ||
bool) const; | ||
}; | ||
|
||
} // namespace detail | ||
|
||
HEYOKA_DLL_PUBLIC expression eq(expression, expression); | ||
HEYOKA_DLL_PUBLIC expression neq(expression, expression); | ||
HEYOKA_DLL_PUBLIC expression lt(expression, expression); | ||
HEYOKA_DLL_PUBLIC expression gt(expression, expression); | ||
HEYOKA_DLL_PUBLIC expression lte(expression, expression); | ||
HEYOKA_DLL_PUBLIC expression gte(expression, expression); | ||
|
||
#define HEYOKA_DECLARE_REL_OVERLOADS(type) \ | ||
HEYOKA_DLL_PUBLIC expression eq(expression, type); \ | ||
HEYOKA_DLL_PUBLIC expression eq(type, expression); \ | ||
HEYOKA_DLL_PUBLIC expression neq(expression, type); \ | ||
HEYOKA_DLL_PUBLIC expression neq(type, expression); \ | ||
HEYOKA_DLL_PUBLIC expression lt(expression, type); \ | ||
HEYOKA_DLL_PUBLIC expression lt(type, expression); \ | ||
HEYOKA_DLL_PUBLIC expression gt(expression, type); \ | ||
HEYOKA_DLL_PUBLIC expression gt(type, expression); \ | ||
HEYOKA_DLL_PUBLIC expression lte(expression, type); \ | ||
HEYOKA_DLL_PUBLIC expression lte(type, expression); \ | ||
HEYOKA_DLL_PUBLIC expression gte(expression, type); \ | ||
HEYOKA_DLL_PUBLIC expression gte(type, expression); | ||
|
||
HEYOKA_DECLARE_REL_OVERLOADS(float); | ||
HEYOKA_DECLARE_REL_OVERLOADS(double); | ||
HEYOKA_DECLARE_REL_OVERLOADS(long double); | ||
|
||
#if defined(HEYOKA_HAVE_REAL128) | ||
|
||
HEYOKA_DECLARE_REL_OVERLOADS(mppp::real128); | ||
|
||
#endif | ||
|
||
#if defined(HEYOKA_HAVE_REAL) | ||
|
||
HEYOKA_DECLARE_REL_OVERLOADS(mppp::real); | ||
|
||
#endif | ||
|
||
#undef HEYOKA_DECLARE_REL_OVERLOADS | ||
|
||
HEYOKA_END_NAMESPACE | ||
|
||
HEYOKA_S11N_FUNC_EXPORT_KEY(heyoka::detail::rel_impl) | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
// Copyright 2020, 2021, 2022, 2023, 2024 Francesco Biscani ([email protected]), Dario Izzo ([email protected]) | ||
// | ||
// This file is part of the heyoka library. | ||
// | ||
// This Source Code Form is subject to the terms of the Mozilla | ||
// Public License v. 2.0. If a copy of the MPL was not distributed | ||
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
#ifndef HEYOKA_MATH_SELECT_HPP | ||
#define HEYOKA_MATH_SELECT_HPP | ||
|
||
#include <heyoka/config.hpp> | ||
|
||
#include <cstdint> | ||
#include <vector> | ||
|
||
#if defined(HEYOKA_HAVE_REAL128) | ||
|
||
#include <mp++/real128.hpp> | ||
|
||
#endif | ||
|
||
#if defined(HEYOKA_HAVE_REAL) | ||
|
||
#include <mp++/real.hpp> | ||
|
||
#endif | ||
|
||
#include <heyoka/detail/fwd_decl.hpp> | ||
#include <heyoka/detail/llvm_fwd.hpp> | ||
#include <heyoka/detail/visibility.hpp> | ||
#include <heyoka/func.hpp> | ||
#include <heyoka/s11n.hpp> | ||
|
||
HEYOKA_BEGIN_NAMESPACE | ||
|
||
namespace detail | ||
{ | ||
|
||
class HEYOKA_DLL_PUBLIC select_impl : public func_base | ||
{ | ||
friend class boost::serialization::access; | ||
template <typename Archive> | ||
void serialize(Archive &ar, unsigned) | ||
{ | ||
ar &boost::serialization::base_object<func_base>(*this); | ||
} | ||
|
||
public: | ||
select_impl(); | ||
explicit select_impl(expression, expression, expression); | ||
|
||
[[nodiscard]] std::vector<expression> gradient() const; | ||
|
||
[[nodiscard]] llvm::Value *llvm_eval(llvm_state &, llvm::Type *, const std::vector<llvm::Value *> &, llvm::Value *, | ||
llvm::Value *, llvm::Value *, std::uint32_t, bool) const; | ||
|
||
[[nodiscard]] llvm::Function *llvm_c_eval_func(llvm_state &, llvm::Type *, std::uint32_t, bool) const; | ||
|
||
[[nodiscard]] llvm::Value *taylor_diff(llvm_state &, llvm::Type *, const std::vector<std::uint32_t> &, | ||
const std::vector<llvm::Value *> &, llvm::Value *, llvm::Value *, | ||
std::uint32_t, std::uint32_t, std::uint32_t, std::uint32_t, bool) const; | ||
|
||
[[nodiscard]] llvm::Function *taylor_c_diff_func(llvm_state &, llvm::Type *, std::uint32_t, std::uint32_t, | ||
bool) const; | ||
}; | ||
|
||
} // namespace detail | ||
|
||
HEYOKA_DLL_PUBLIC expression select(expression, expression, expression); | ||
|
||
#define HEYOKA_DECLARE_SELECT_OVERLOADS(type) \ | ||
HEYOKA_DLL_PUBLIC expression select(expression, type, type); \ | ||
HEYOKA_DLL_PUBLIC expression select(type, expression, type); \ | ||
HEYOKA_DLL_PUBLIC expression select(type, type, expression); \ | ||
HEYOKA_DLL_PUBLIC expression select(expression, expression, type); \ | ||
HEYOKA_DLL_PUBLIC expression select(expression, type, expression); \ | ||
HEYOKA_DLL_PUBLIC expression select(type, expression, expression) | ||
|
||
HEYOKA_DECLARE_SELECT_OVERLOADS(float); | ||
HEYOKA_DECLARE_SELECT_OVERLOADS(double); | ||
HEYOKA_DECLARE_SELECT_OVERLOADS(long double); | ||
|
||
#if defined(HEYOKA_HAVE_REAL128) | ||
|
||
HEYOKA_DECLARE_SELECT_OVERLOADS(mppp::real128); | ||
|
||
#endif | ||
|
||
#if defined(HEYOKA_HAVE_REAL) | ||
|
||
HEYOKA_DECLARE_SELECT_OVERLOADS(mppp::real); | ||
|
||
#endif | ||
|
||
#undef HEYOKA_DECLARE_SELECT_OVERLOADS | ||
|
||
HEYOKA_END_NAMESPACE | ||
|
||
HEYOKA_S11N_FUNC_EXPORT_KEY(heyoka::detail::select_impl) | ||
|
||
#endif |
Oops, something went wrong.