-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Many functions from <http://www.w3.org/2005/xpath-functions/math#>, like `sqrt`, `sin`, `cos`, ... are already implemented in Qlever, but not `pow`. This PR implements `math:pow(base, exp)`.
- Loading branch information
Showing
5 changed files
with
34 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
// Chair of Algorithms and Data Structures. | ||
// Author: Johannes Kalmbach <[email protected]> | ||
#include "engine/sparqlExpressions/NaryExpressionImpl.h" | ||
#include "engine/sparqlExpressions/SparqlExpressionValueGetters.h" | ||
|
||
namespace sparqlExpression { | ||
namespace detail { | ||
|
@@ -33,6 +34,13 @@ inline auto subtract = makeNumericExpression<std::minus<>>(); | |
NARY_EXPRESSION(SubtractExpression, 2, | ||
FV<decltype(subtract), NumericValueGetter>); | ||
|
||
// Power. | ||
inline auto powImpl = [](double base, double exp) { | ||
return std::pow(base, exp); | ||
}; | ||
inline auto pow = makeNumericExpression<decltype(powImpl)>(); | ||
NARY_EXPRESSION(PowExpression, 2, FV<decltype(pow), NumericValueGetter>); | ||
|
||
// Or | ||
inline auto orLambda = [](TernaryBool a, TernaryBool b) { | ||
using enum TernaryBool; | ||
|
@@ -96,4 +104,9 @@ SparqlExpression::Ptr makeOrExpression(SparqlExpression::Ptr child1, | |
SparqlExpression::Ptr child2) { | ||
return std::make_unique<OrExpression>(std::move(child1), std::move(child2)); | ||
} | ||
|
||
SparqlExpression::Ptr makePowExpression(SparqlExpression::Ptr child1, | ||
SparqlExpression::Ptr child2) { | ||
return std::make_unique<PowExpression>(std::move(child1), std::move(child2)); | ||
} | ||
} // namespace sparqlExpression |
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