Skip to content

Commit

Permalink
Add Root type
Browse files Browse the repository at this point in the history
  • Loading branch information
fintarin committed Jul 18, 2023
1 parent fecc994 commit 3590682
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/fintamath/core/MathObjectTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ enum class MathObjectType : MathObjectTypeId {
Lg,
Exp,
Sqrt,
Root,
Sin,
Cos,
Tan,
Expand Down
4 changes: 4 additions & 0 deletions include/fintamath/functions/powers/Root.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ class Root : public IFunctionCRTP<INumber, Root, INumber, INumber> {
return "root";
}

static MathObjectTypeId getTypeIdStatic() {
return MathObjectTypeId(MathObjectType::Root);
}

protected:
std::unique_ptr<IMathObject> call(const ArgumentsRefVector &argsVect) const override;

Expand Down
5 changes: 5 additions & 0 deletions tests/src/functions/powers/RootTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,8 @@ TEST(RootTests, callTest) {
EXPECT_THROW(f(), InvalidInputFunctionException);
EXPECT_THROW(f(Integer(1), Integer(1), Integer(1)), InvalidInputFunctionException);
}

TEST(RootTests, getTypeIdTest) {
EXPECT_EQ(Root::getTypeIdStatic(), MathObjectTypeId(MathObjectType::Root));
EXPECT_EQ(Root().getTypeId(), MathObjectTypeId(MathObjectType::Root));
}

0 comments on commit 3590682

Please sign in to comment.