Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recursively check for Evaluate() in MOO #283

Merged
merged 10 commits into from
Apr 10, 2021
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
* Add clarifying comments in problems/ implementations
([#276](https://github.com/mlpack/ensmallen/pull/276)).

* CheckArbitraryFunctionTypeAPI extended for MOO support
([#283](https://github.com/mlpack/ensmallen/pull/283)).

### ensmallen 2.16.1: "Severely Dented Can Of Polyurethane"
###### 2021-03-02
* Fix test compilation issue when `ENS_USE_OPENMP` is set
Expand Down
22 changes: 21 additions & 1 deletion include/ensmallen_bits/function/static_checks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ inline void CheckSparseFunctionTypeAPI()
/**
* Perform checks for the ArbitraryFunctionType API.
*/
template<typename FunctionType, typename MatType>
template<typename FunctionType, typename MatType, std::size_t I = 0U>
jonpsy marked this conversation as resolved.
Show resolved Hide resolved
inline void CheckArbitraryFunctionTypeAPI()
{
#ifndef ENS_DISABLE_TYPE_CHECKS
Expand All @@ -387,6 +387,26 @@ inline void CheckArbitraryFunctionTypeAPI()
#endif
}

template<typename... FunctionAndMatTypes, std::size_t I = 0U>
typename std::enable_if<I < sizeof...(FunctionAndMatTypes) - 2U, void>::type
CheckArbitraryFunctionTypeAPI()
{
#ifndef ENS_DISABLE_TYPE_CHECKS
constexpr size_t size = sizeof...(FunctionAndMatTypes);
using TupleType = typename std::tuple<FunctionAndMatTypes...>;
using FunctionType = typename std::tuple_element<I, TupleType>::type;
using MatType = typename std::tuple_element<size - 1, TupleType>::type;

static_assert(CheckEvaluate<FunctionType, MatType, MatType>::value,
"One of the provided FunctionType does not have a correct definition of Evaluate(). "
"Please check that the corresponding FunctionType fully satisfies the requirements"
jonpsy marked this conversation as resolved.
Show resolved Hide resolved
"of the ArbitraryFunctionType API; see the optimizer tutorial for "
"more details.");

CheckArbitraryFunctionTypeAPI<FunctionAndMatTypes..., I + 1>();
#endif
}

/**
* Perform checks for the ResolvableFunctionType API.
*/
Expand Down