diff --git a/fl/Operation.h b/fl/Operation.h index 75118aa..32c5e77 100644 --- a/fl/Operation.h +++ b/fl/Operation.h @@ -74,6 +74,14 @@ namespace fl { static scalar logicalAnd(scalar a, scalar b); static scalar logicalOr(scalar a, scalar b); static scalar negate(scalar a); + static scalar gt(scalar a, scalar b); //greater than + static scalar ge(scalar a, scalar b); //greater than or equal to + static scalar eq(scalar a, scalar b); //equal to + static scalar le(scalar a, scalar b); //less than or equal to + static scalar lt(scalar a, scalar b); //less than + static scalar logicalNot(scalar a); + + static bool increment(std::vector& x, std::vector& min, std::vector& max); static bool increment(std::vector& x, int position, std::vector& min, std::vector& max); diff --git a/src/Operation.cpp b/src/Operation.cpp index 133bdb7..ce7abb2 100644 --- a/src/Operation.cpp +++ b/src/Operation.cpp @@ -110,6 +110,27 @@ namespace fl { scalar Operation::negate(scalar a) { return -a; } + scalar Operation::gt(scalar a, scalar b) { + return isGt(a, b); + } + scalar Operation::ge(scalar a, scalar b) { + return isGE(a, b); + } + scalar Operation::eq(scalar a, scalar b) { + return isEq(a, b); + } + scalar Operation::le(scalar a, scalar b) { + return isLE(a, b); + } + scalar Operation::lt(scalar a, scalar b) { + return isLt(a, b); + } + scalar Operation::logicalNot(scalar a) { + return isEq(a, 1.0) ? 0.0 : 1.0; //Implementation in Operation.cpp + } + + + bool Operation::increment(std::vector& x, std::vector& min, std::vector& max) { return increment(x, (int) x.size() - 1, min, max); diff --git a/src/term/Function.cpp b/src/term/Function.cpp index dd3bd2f..5aa836e 100644 --- a/src/term/Function.cpp +++ b/src/term/Function.cpp @@ -227,6 +227,8 @@ namespace fl { // (!) Logical and (~) Bitwise NOT // this->_unaryOperators["!"] = new Operator("!", std::logical_not, p, 1); // ~ negates a number + this->operators["!"] = new Operator("!", fl::Op::logicalNot, p, 1); + this->operators["~"] = new Operator("~", fl::Op::negate, p, 1); --p; //Power this->operators["^"] = new Operator("^", std::pow, p, 1); @@ -280,6 +282,11 @@ namespace fl { this->functions["pow"] = new BuiltInFunction("pow", &(std::pow)); this->functions["atan2"] = new BuiltInFunction("atan2", &(std::atan2)); this->functions["fmod"] = new BuiltInFunction("fmod", &(std::fmod)); + this->functions["gt"] = new BuiltInFunction("gt", &(fl::Op::gt)); + this->functions["lt"] = new BuiltInFunction("lt", &(fl::Op::lt)); + this->functions["ge"] = new BuiltInFunction("ge", &(fl::Op::ge)); + this->functions["le"] = new BuiltInFunction("le", &(fl::Op::le)); + this->functions["eq"] = new BuiltInFunction("eq", &(fl::Op::eq)); } std::string Function::space(const std::string& formula) const {