MCPcopy Create free account
hub / github.com/BowenFu/matchit.cpp / relu

Function relu

sample/relu.cpp:4–13  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2#include <iostream>
3
4constexpr double relu(double value)
5{
6 using namespace matchit;
7 return match(value)(
8 // clang-format off
9 pattern | (_ >= 0) = expr(value),
10 pattern | _ = expr(0)
11 // clang-format on
12 );
13}
14
15static_assert(relu(5) == 5);
16static_assert(relu(-5) == 0);

Callers 2

relu.cppFile · 0.85
mainFunction · 0.85

Calls 2

matchFunction · 0.50
exprFunction · 0.50

Tested by

no test coverage detected