summaryrefslogtreecommitdiff
path: root/fuzzylite/src/norm
diff options
context:
space:
mode:
Diffstat (limited to 'fuzzylite/src/norm')
-rw-r--r--fuzzylite/src/norm/s/AlgebraicSum.cpp26
-rw-r--r--fuzzylite/src/norm/s/BoundedSum.cpp28
-rw-r--r--fuzzylite/src/norm/s/DrasticSum.cpp28
-rw-r--r--fuzzylite/src/norm/s/EinsteinSum.cpp26
-rw-r--r--fuzzylite/src/norm/s/HamacherSum.cpp29
-rw-r--r--fuzzylite/src/norm/s/Maximum.cpp28
-rw-r--r--fuzzylite/src/norm/s/NilpotentMaximum.cpp32
-rw-r--r--fuzzylite/src/norm/s/NormalizedSum.cpp31
-rw-r--r--fuzzylite/src/norm/s/SNormFunction.cpp65
-rw-r--r--fuzzylite/src/norm/s/UnboundedSum.cpp43
-rw-r--r--fuzzylite/src/norm/t/AlgebraicProduct.cpp26
-rw-r--r--fuzzylite/src/norm/t/BoundedDifference.cpp27
-rw-r--r--fuzzylite/src/norm/t/DrasticProduct.cpp28
-rw-r--r--fuzzylite/src/norm/t/EinsteinProduct.cpp26
-rw-r--r--fuzzylite/src/norm/t/HamacherProduct.cpp28
-rw-r--r--fuzzylite/src/norm/t/Minimum.cpp28
-rw-r--r--fuzzylite/src/norm/t/NilpotentMinimum.cpp29
-rw-r--r--fuzzylite/src/norm/t/TNormFunction.cpp66
18 files changed, 363 insertions, 231 deletions
diff --git a/fuzzylite/src/norm/s/AlgebraicSum.cpp b/fuzzylite/src/norm/s/AlgebraicSum.cpp
index e96c1a7..0497f23 100644
--- a/fuzzylite/src/norm/s/AlgebraicSum.cpp
+++ b/fuzzylite/src/norm/s/AlgebraicSum.cpp
@@ -1,25 +1,17 @@
/*
- Author: Juan Rada-Vilela, Ph.D.
- Copyright (C) 2010-2014 FuzzyLite Limited
- All rights reserved
+ fuzzylite (R), a fuzzy logic control library in C++.
+ Copyright (C) 2010-2017 FuzzyLite Limited. All rights reserved.
+ Author: Juan Rada-Vilela, Ph.D. <jcrada@fuzzylite.com>
This file is part of fuzzylite.
fuzzylite is free software: you can redistribute it and/or modify it under
- the terms of the GNU Lesser General Public License as published by the Free
- Software Foundation, either version 3 of the License, or (at your option)
- any later version.
+ the terms of the FuzzyLite License included with the software.
- fuzzylite is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with fuzzylite. If not, see <http://www.gnu.org/licenses/>.
-
- fuzzylite™ is a trademark of FuzzyLite Limited.
+ You should have received a copy of the FuzzyLite License along with
+ fuzzylite. If not, see <http://www.fuzzylite.com/license/>.
+ fuzzylite is a registered trademark of FuzzyLite Limited.
*/
#include "fl/norm/s/AlgebraicSum.h"
@@ -30,6 +22,10 @@ namespace fl {
return "AlgebraicSum";
}
+ Complexity AlgebraicSum::complexity() const {
+ return Complexity().arithmetic(3);
+ }
+
scalar AlgebraicSum::compute(scalar a, scalar b) const {
return a + b - (a * b);
}
diff --git a/fuzzylite/src/norm/s/BoundedSum.cpp b/fuzzylite/src/norm/s/BoundedSum.cpp
index 9c050c8..b1cb42b 100644
--- a/fuzzylite/src/norm/s/BoundedSum.cpp
+++ b/fuzzylite/src/norm/s/BoundedSum.cpp
@@ -1,35 +1,33 @@
/*
- Author: Juan Rada-Vilela, Ph.D.
- Copyright (C) 2010-2014 FuzzyLite Limited
- All rights reserved
+ fuzzylite (R), a fuzzy logic control library in C++.
+ Copyright (C) 2010-2017 FuzzyLite Limited. All rights reserved.
+ Author: Juan Rada-Vilela, Ph.D. <jcrada@fuzzylite.com>
This file is part of fuzzylite.
fuzzylite is free software: you can redistribute it and/or modify it under
- the terms of the GNU Lesser General Public License as published by the Free
- Software Foundation, either version 3 of the License, or (at your option)
- any later version.
+ the terms of the FuzzyLite License included with the software.
- fuzzylite is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with fuzzylite. If not, see <http://www.gnu.org/licenses/>.
-
- fuzzylite™ is a trademark of FuzzyLite Limited.
+ You should have received a copy of the FuzzyLite License along with
+ fuzzylite. If not, see <http://www.fuzzylite.com/license/>.
+ fuzzylite is a registered trademark of FuzzyLite Limited.
*/
#include "fl/norm/s/BoundedSum.h"
+#include "fl/Operation.h"
+
namespace fl {
std::string BoundedSum::className() const {
return "BoundedSum";
}
+ Complexity BoundedSum::complexity() const {
+ return Complexity().arithmetic(1).function(1);
+ }
+
scalar BoundedSum::compute(scalar a, scalar b) const {
return Op::min(scalar(1.0), a + b);
}
diff --git a/fuzzylite/src/norm/s/DrasticSum.cpp b/fuzzylite/src/norm/s/DrasticSum.cpp
index c0629db..b0d9f1e 100644
--- a/fuzzylite/src/norm/s/DrasticSum.cpp
+++ b/fuzzylite/src/norm/s/DrasticSum.cpp
@@ -1,35 +1,33 @@
/*
- Author: Juan Rada-Vilela, Ph.D.
- Copyright (C) 2010-2014 FuzzyLite Limited
- All rights reserved
+ fuzzylite (R), a fuzzy logic control library in C++.
+ Copyright (C) 2010-2017 FuzzyLite Limited. All rights reserved.
+ Author: Juan Rada-Vilela, Ph.D. <jcrada@fuzzylite.com>
This file is part of fuzzylite.
fuzzylite is free software: you can redistribute it and/or modify it under
- the terms of the GNU Lesser General Public License as published by the Free
- Software Foundation, either version 3 of the License, or (at your option)
- any later version.
+ the terms of the FuzzyLite License included with the software.
- fuzzylite is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with fuzzylite. If not, see <http://www.gnu.org/licenses/>.
-
- fuzzylite™ is a trademark of FuzzyLite Limited.
+ You should have received a copy of the FuzzyLite License along with
+ fuzzylite. If not, see <http://www.fuzzylite.com/license/>.
+ fuzzylite is a registered trademark of FuzzyLite Limited.
*/
#include "fl/norm/s/DrasticSum.h"
+#include "fl/Operation.h"
+
namespace fl {
std::string DrasticSum::className() const {
return "DrasticSum";
}
+ Complexity DrasticSum::complexity() const {
+ return Complexity().comparison(1).function(2);
+ }
+
scalar DrasticSum::compute(scalar a, scalar b) const {
if (Op::isEq(Op::min(a, b), 0.0)) {
return Op::max(a, b);
diff --git a/fuzzylite/src/norm/s/EinsteinSum.cpp b/fuzzylite/src/norm/s/EinsteinSum.cpp
index ec0fbd8..a638c7b 100644
--- a/fuzzylite/src/norm/s/EinsteinSum.cpp
+++ b/fuzzylite/src/norm/s/EinsteinSum.cpp
@@ -1,25 +1,17 @@
/*
- Author: Juan Rada-Vilela, Ph.D.
- Copyright (C) 2010-2014 FuzzyLite Limited
- All rights reserved
+ fuzzylite (R), a fuzzy logic control library in C++.
+ Copyright (C) 2010-2017 FuzzyLite Limited. All rights reserved.
+ Author: Juan Rada-Vilela, Ph.D. <jcrada@fuzzylite.com>
This file is part of fuzzylite.
fuzzylite is free software: you can redistribute it and/or modify it under
- the terms of the GNU Lesser General Public License as published by the Free
- Software Foundation, either version 3 of the License, or (at your option)
- any later version.
+ the terms of the FuzzyLite License included with the software.
- fuzzylite is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with fuzzylite. If not, see <http://www.gnu.org/licenses/>.
-
- fuzzylite™ is a trademark of FuzzyLite Limited.
+ You should have received a copy of the FuzzyLite License along with
+ fuzzylite. If not, see <http://www.fuzzylite.com/license/>.
+ fuzzylite is a registered trademark of FuzzyLite Limited.
*/
#include "fl/norm/s/EinsteinSum.h"
@@ -30,6 +22,10 @@ namespace fl {
return "EinsteinSum";
}
+ Complexity EinsteinSum::complexity() const {
+ return Complexity().arithmetic(4);
+ }
+
scalar EinsteinSum::compute(scalar a, scalar b) const {
return (a + b) / (1.0 + a * b);
}
diff --git a/fuzzylite/src/norm/s/HamacherSum.cpp b/fuzzylite/src/norm/s/HamacherSum.cpp
index f9c0994..41242ee 100644
--- a/fuzzylite/src/norm/s/HamacherSum.cpp
+++ b/fuzzylite/src/norm/s/HamacherSum.cpp
@@ -1,36 +1,35 @@
/*
- Author: Juan Rada-Vilela, Ph.D.
- Copyright (C) 2010-2014 FuzzyLite Limited
- All rights reserved
+ fuzzylite (R), a fuzzy logic control library in C++.
+ Copyright (C) 2010-2017 FuzzyLite Limited. All rights reserved.
+ Author: Juan Rada-Vilela, Ph.D. <jcrada@fuzzylite.com>
This file is part of fuzzylite.
fuzzylite is free software: you can redistribute it and/or modify it under
- the terms of the GNU Lesser General Public License as published by the Free
- Software Foundation, either version 3 of the License, or (at your option)
- any later version.
+ the terms of the FuzzyLite License included with the software.
- fuzzylite is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with fuzzylite. If not, see <http://www.gnu.org/licenses/>.
-
- fuzzylite™ is a trademark of FuzzyLite Limited.
+ You should have received a copy of the FuzzyLite License along with
+ fuzzylite. If not, see <http://www.fuzzylite.com/license/>.
+ fuzzylite is a registered trademark of FuzzyLite Limited.
*/
#include "fl/norm/s/HamacherSum.h"
+#include "fl/Operation.h"
+
namespace fl {
std::string HamacherSum::className() const {
return "HamacherSum";
}
+ Complexity HamacherSum::complexity() const {
+ return Complexity().arithmetic(7);
+ }
+
scalar HamacherSum::compute(scalar a, scalar b) const {
+ if (Op::isEq(a * b, 1.0)) return 1.0;
return (a + b - 2.0 * a * b) / (1.0 - a * b);
}
diff --git a/fuzzylite/src/norm/s/Maximum.cpp b/fuzzylite/src/norm/s/Maximum.cpp
index ed8a839..5277d49 100644
--- a/fuzzylite/src/norm/s/Maximum.cpp
+++ b/fuzzylite/src/norm/s/Maximum.cpp
@@ -1,35 +1,33 @@
/*
- Author: Juan Rada-Vilela, Ph.D.
- Copyright (C) 2010-2014 FuzzyLite Limited
- All rights reserved
+ fuzzylite (R), a fuzzy logic control library in C++.
+ Copyright (C) 2010-2017 FuzzyLite Limited. All rights reserved.
+ Author: Juan Rada-Vilela, Ph.D. <jcrada@fuzzylite.com>
This file is part of fuzzylite.
fuzzylite is free software: you can redistribute it and/or modify it under
- the terms of the GNU Lesser General Public License as published by the Free
- Software Foundation, either version 3 of the License, or (at your option)
- any later version.
+ the terms of the FuzzyLite License included with the software.
- fuzzylite is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with fuzzylite. If not, see <http://www.gnu.org/licenses/>.
-
- fuzzylite™ is a trademark of FuzzyLite Limited.
+ You should have received a copy of the FuzzyLite License along with
+ fuzzylite. If not, see <http://www.fuzzylite.com/license/>.
+ fuzzylite is a registered trademark of FuzzyLite Limited.
*/
#include "fl/norm/s/Maximum.h"
+#include "fl/Operation.h"
+
namespace fl {
std::string Maximum::className() const {
return "Maximum";
}
+ Complexity Maximum::complexity() const {
+ return Complexity().function(1);
+ }
+
scalar Maximum::compute(scalar a, scalar b) const {
return Op::max(a, b);
}
diff --git a/fuzzylite/src/norm/s/NilpotentMaximum.cpp b/fuzzylite/src/norm/s/NilpotentMaximum.cpp
index 0a09136..7c63999 100644
--- a/fuzzylite/src/norm/s/NilpotentMaximum.cpp
+++ b/fuzzylite/src/norm/s/NilpotentMaximum.cpp
@@ -1,38 +1,36 @@
/*
- Author: Juan Rada-Vilela, Ph.D.
- Copyright (C) 2010-2014 FuzzyLite Limited
- All rights reserved
+ fuzzylite (R), a fuzzy logic control library in C++.
+ Copyright (C) 2010-2017 FuzzyLite Limited. All rights reserved.
+ Author: Juan Rada-Vilela, Ph.D. <jcrada@fuzzylite.com>
This file is part of fuzzylite.
fuzzylite is free software: you can redistribute it and/or modify it under
- the terms of the GNU Lesser General Public License as published by the Free
- Software Foundation, either version 3 of the License, or (at your option)
- any later version.
+ the terms of the FuzzyLite License included with the software.
- fuzzylite is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with fuzzylite. If not, see <http://www.gnu.org/licenses/>.
-
- fuzzylite™ is a trademark of FuzzyLite Limited.
+ You should have received a copy of the FuzzyLite License along with
+ fuzzylite. If not, see <http://www.fuzzylite.com/license/>.
+ fuzzylite is a registered trademark of FuzzyLite Limited.
*/
#include "fl/norm/s/NilpotentMaximum.h"
+#include "fl/Operation.h"
+
namespace fl {
std::string NilpotentMaximum::className() const {
return "NilpotentMaximum";
}
+ Complexity NilpotentMaximum::complexity() const {
+ return Complexity().comparison(1).arithmetic(1).function(1);
+ }
+
scalar NilpotentMaximum::compute(scalar a, scalar b) const {
if (Op::isLt(a + b, 1.0)) {
- return std::max(a, b);
+ return Op::max(a, b);
}
return 1.0;
}
@@ -45,6 +43,4 @@ namespace fl {
return new NilpotentMaximum;
}
-
}
-
diff --git a/fuzzylite/src/norm/s/NormalizedSum.cpp b/fuzzylite/src/norm/s/NormalizedSum.cpp
index 94ad5ea..c420ed1 100644
--- a/fuzzylite/src/norm/s/NormalizedSum.cpp
+++ b/fuzzylite/src/norm/s/NormalizedSum.cpp
@@ -1,37 +1,35 @@
/*
- Author: Juan Rada-Vilela, Ph.D.
- Copyright (C) 2010-2014 FuzzyLite Limited
- All rights reserved
+ fuzzylite (R), a fuzzy logic control library in C++.
+ Copyright (C) 2010-2017 FuzzyLite Limited. All rights reserved.
+ Author: Juan Rada-Vilela, Ph.D. <jcrada@fuzzylite.com>
This file is part of fuzzylite.
fuzzylite is free software: you can redistribute it and/or modify it under
- the terms of the GNU Lesser General Public License as published by the Free
- Software Foundation, either version 3 of the License, or (at your option)
- any later version.
+ the terms of the FuzzyLite License included with the software.
- fuzzylite is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with fuzzylite. If not, see <http://www.gnu.org/licenses/>.
-
- fuzzylite™ is a trademark of FuzzyLite Limited.
+ You should have received a copy of the FuzzyLite License along with
+ fuzzylite. If not, see <http://www.fuzzylite.com/license/>.
+ fuzzylite is a registered trademark of FuzzyLite Limited.
*/
#include "fl/norm/s/NormalizedSum.h"
+#include "fl/Operation.h"
+
namespace fl {
std::string NormalizedSum::className() const {
return "NormalizedSum";
}
+ Complexity NormalizedSum::complexity() const {
+ return Complexity().arithmetic(3).function(1);
+ }
+
scalar NormalizedSum::compute(scalar a, scalar b) const {
- return a + b / Op::max(scalar(1.0), Op::max(a, b));
+ return (a + b) / Op::max(scalar(1.0), a + b);
}
NormalizedSum* NormalizedSum::clone() const {
@@ -42,5 +40,4 @@ namespace fl {
return new NormalizedSum;
}
-
}
diff --git a/fuzzylite/src/norm/s/SNormFunction.cpp b/fuzzylite/src/norm/s/SNormFunction.cpp
new file mode 100644
index 0000000..f8d9e42
--- /dev/null
+++ b/fuzzylite/src/norm/s/SNormFunction.cpp
@@ -0,0 +1,65 @@
+/*
+ fuzzylite (R), a fuzzy logic control library in C++.
+ Copyright (C) 2010-2017 FuzzyLite Limited. All rights reserved.
+ Author: Juan Rada-Vilela, Ph.D. <jcrada@fuzzylite.com>
+
+ This file is part of fuzzylite.
+
+ fuzzylite is free software: you can redistribute it and/or modify it under
+ the terms of the FuzzyLite License included with the software.
+
+ You should have received a copy of the FuzzyLite License along with
+ fuzzylite. If not, see <http://www.fuzzylite.com/license/>.
+
+ fuzzylite is a registered trademark of FuzzyLite Limited.
+ */
+
+#include "fl/norm/s/SNormFunction.h"
+
+namespace fl {
+
+ SNormFunction::SNormFunction(const std::string& formula) : SNorm() {
+ _function.variables["a"] = fl::nan;
+ _function.variables["b"] = fl::nan;
+ if (not formula.empty()) {
+ _function.load(formula);
+ }
+ }
+
+ std::string SNormFunction::className() const {
+ return "SNormFunction";
+ }
+
+ Complexity SNormFunction::complexity() const {
+ if (_function.root())
+ return _function.complexity().function(2 * std::log(scalar(_function.variables.size())));
+ return _function.complexity();
+ }
+
+ scalar SNormFunction::compute(scalar a, scalar b) const {
+ _function.variables["a"] = a;
+ _function.variables["b"] = b;
+ return _function.evaluate();
+ }
+
+ Function& SNormFunction::function() {
+ return this->_function;
+ }
+
+ void SNormFunction::setFormula(const std::string& formula) {
+ this->_function.load(formula);
+ }
+
+ std::string SNormFunction::getFormula() const {
+ return _function.getFormula();
+ }
+
+ SNormFunction* SNormFunction::clone() const {
+ return new SNormFunction(*this);
+ }
+
+ SNorm* SNormFunction::constructor() {
+ return new SNormFunction;
+ }
+
+}
diff --git a/fuzzylite/src/norm/s/UnboundedSum.cpp b/fuzzylite/src/norm/s/UnboundedSum.cpp
new file mode 100644
index 0000000..adee6ad
--- /dev/null
+++ b/fuzzylite/src/norm/s/UnboundedSum.cpp
@@ -0,0 +1,43 @@
+/*
+ fuzzylite (R), a fuzzy logic control library in C++.
+ Copyright (C) 2010-2017 FuzzyLite Limited. All rights reserved.
+ Author: Juan Rada-Vilela, Ph.D. <jcrada@fuzzylite.com>
+
+ This file is part of fuzzylite.
+
+ fuzzylite is free software: you can redistribute it and/or modify it under
+ the terms of the FuzzyLite License included with the software.
+
+ You should have received a copy of the FuzzyLite License along with
+ fuzzylite. If not, see <http://www.fuzzylite.com/license/>.
+
+ fuzzylite is a registered trademark of FuzzyLite Limited.
+ */
+
+#include "fl/norm/s/UnboundedSum.h"
+
+#include "fl/Operation.h"
+
+namespace fl {
+
+ std::string UnboundedSum::className() const {
+ return "UnboundedSum";
+ }
+
+ Complexity UnboundedSum::complexity() const {
+ return Complexity().arithmetic(1);
+ }
+
+ scalar UnboundedSum::compute(scalar a, scalar b) const {
+ return a + b;
+ }
+
+ UnboundedSum* UnboundedSum::clone() const {
+ return new UnboundedSum(*this);
+ }
+
+ SNorm* UnboundedSum::constructor() {
+ return new UnboundedSum;
+ }
+
+}
diff --git a/fuzzylite/src/norm/t/AlgebraicProduct.cpp b/fuzzylite/src/norm/t/AlgebraicProduct.cpp
index eee1061..eefe309 100644
--- a/fuzzylite/src/norm/t/AlgebraicProduct.cpp
+++ b/fuzzylite/src/norm/t/AlgebraicProduct.cpp
@@ -1,25 +1,17 @@
/*
- Author: Juan Rada-Vilela, Ph.D.
- Copyright (C) 2010-2014 FuzzyLite Limited
- All rights reserved
+ fuzzylite (R), a fuzzy logic control library in C++.
+ Copyright (C) 2010-2017 FuzzyLite Limited. All rights reserved.
+ Author: Juan Rada-Vilela, Ph.D. <jcrada@fuzzylite.com>
This file is part of fuzzylite.
fuzzylite is free software: you can redistribute it and/or modify it under
- the terms of the GNU Lesser General Public License as published by the Free
- Software Foundation, either version 3 of the License, or (at your option)
- any later version.
+ the terms of the FuzzyLite License included with the software.
- fuzzylite is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with fuzzylite. If not, see <http://www.gnu.org/licenses/>.
-
- fuzzylite™ is a trademark of FuzzyLite Limited.
+ You should have received a copy of the FuzzyLite License along with
+ fuzzylite. If not, see <http://www.fuzzylite.com/license/>.
+ fuzzylite is a registered trademark of FuzzyLite Limited.
*/
#include "fl/norm/t/AlgebraicProduct.h"
@@ -30,6 +22,10 @@ namespace fl {
return "AlgebraicProduct";
}
+ Complexity AlgebraicProduct::complexity() const {
+ return Complexity().arithmetic(1);
+ }
+
scalar AlgebraicProduct::compute(scalar a, scalar b) const {
return a * b;
}
diff --git a/fuzzylite/src/norm/t/BoundedDifference.cpp b/fuzzylite/src/norm/t/BoundedDifference.cpp
index aa4fead..3775aa4 100644
--- a/fuzzylite/src/norm/t/BoundedDifference.cpp
+++ b/fuzzylite/src/norm/t/BoundedDifference.cpp
@@ -1,29 +1,22 @@
/*
- Author: Juan Rada-Vilela, Ph.D.
- Copyright (C) 2010-2014 FuzzyLite Limited
- All rights reserved
+ fuzzylite (R), a fuzzy logic control library in C++.
+ Copyright (C) 2010-2017 FuzzyLite Limited. All rights reserved.
+ Author: Juan Rada-Vilela, Ph.D. <jcrada@fuzzylite.com>
This file is part of fuzzylite.
fuzzylite is free software: you can redistribute it and/or modify it under
- the terms of the GNU Lesser General Public License as published by the Free
- Software Foundation, either version 3 of the License, or (at your option)
- any later version.
+ the terms of the FuzzyLite License included with the software.
- fuzzylite is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with fuzzylite. If not, see <http://www.gnu.org/licenses/>.
-
- fuzzylite™ is a trademark of FuzzyLite Limited.
+ You should have received a copy of the FuzzyLite License along with
+ fuzzylite. If not, see <http://www.fuzzylite.com/license/>.
+ fuzzylite is a registered trademark of FuzzyLite Limited.
*/
#include "fl/norm/t/BoundedDifference.h"
+#include "fl/Operation.h"
namespace fl {
@@ -31,6 +24,10 @@ namespace fl {
return "BoundedDifference";
}
+ Complexity BoundedDifference::complexity() const {
+ return Complexity().arithmetic(2).function(1);
+ }
+
scalar BoundedDifference::compute(scalar a, scalar b) const {
return Op::max(scalar(0.0), a + b - scalar(1.0));
}
diff --git a/fuzzylite/src/norm/t/DrasticProduct.cpp b/fuzzylite/src/norm/t/DrasticProduct.cpp
index 124b79d..5bfdc87 100644
--- a/fuzzylite/src/norm/t/DrasticProduct.cpp
+++ b/fuzzylite/src/norm/t/DrasticProduct.cpp
@@ -1,35 +1,33 @@
/*
- Author: Juan Rada-Vilela, Ph.D.
- Copyright (C) 2010-2014 FuzzyLite Limited
- All rights reserved
+ fuzzylite (R), a fuzzy logic control library in C++.
+ Copyright (C) 2010-2017 FuzzyLite Limited. All rights reserved.
+ Author: Juan Rada-Vilela, Ph.D. <jcrada@fuzzylite.com>
This file is part of fuzzylite.
fuzzylite is free software: you can redistribute it and/or modify it under
- the terms of the GNU Lesser General Public License as published by the Free
- Software Foundation, either version 3 of the License, or (at your option)
- any later version.
+ the terms of the FuzzyLite License included with the software.
- fuzzylite is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with fuzzylite. If not, see <http://www.gnu.org/licenses/>.
-
- fuzzylite™ is a trademark of FuzzyLite Limited.
+ You should have received a copy of the FuzzyLite License along with
+ fuzzylite. If not, see <http://www.fuzzylite.com/license/>.
+ fuzzylite is a registered trademark of FuzzyLite Limited.
*/
#include "fl/norm/t/DrasticProduct.h"
+#include "fl/Operation.h"
+
namespace fl {
std::string DrasticProduct::className() const {
return "DrasticProduct";
}
+ Complexity DrasticProduct::complexity() const {
+ return Complexity().comparison(1).function(2);
+ }
+
scalar DrasticProduct::compute(scalar a, scalar b) const {
if (Op::isEq(Op::max(a, b), 1.0)) {
return Op::min(a, b);
diff --git a/fuzzylite/src/norm/t/EinsteinProduct.cpp b/fuzzylite/src/norm/t/EinsteinProduct.cpp
index ea79188..bbb3966 100644
--- a/fuzzylite/src/norm/t/EinsteinProduct.cpp
+++ b/fuzzylite/src/norm/t/EinsteinProduct.cpp
@@ -1,25 +1,17 @@
/*
- Author: Juan Rada-Vilela, Ph.D.
- Copyright (C) 2010-2014 FuzzyLite Limited
- All rights reserved
+ fuzzylite (R), a fuzzy logic control library in C++.
+ Copyright (C) 2010-2017 FuzzyLite Limited. All rights reserved.
+ Author: Juan Rada-Vilela, Ph.D. <jcrada@fuzzylite.com>
This file is part of fuzzylite.
fuzzylite is free software: you can redistribute it and/or modify it under
- the terms of the GNU Lesser General Public License as published by the Free
- Software Foundation, either version 3 of the License, or (at your option)
- any later version.
+ the terms of the FuzzyLite License included with the software.
- fuzzylite is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with fuzzylite. If not, see <http://www.gnu.org/licenses/>.
-
- fuzzylite™ is a trademark of FuzzyLite Limited.
+ You should have received a copy of the FuzzyLite License along with
+ fuzzylite. If not, see <http://www.fuzzylite.com/license/>.
+ fuzzylite is a registered trademark of FuzzyLite Limited.
*/
#include "fl/norm/t/EinsteinProduct.h"
@@ -30,6 +22,10 @@ namespace fl {
return "EinsteinProduct";
}
+ Complexity EinsteinProduct::complexity() const {
+ return Complexity().arithmetic(6);
+ }
+
scalar EinsteinProduct::compute(scalar a, scalar b) const {
return (a * b) / (2.0 - (a + b - a * b));
}
diff --git a/fuzzylite/src/norm/t/HamacherProduct.cpp b/fuzzylite/src/norm/t/HamacherProduct.cpp
index e3f093e..9416084 100644
--- a/fuzzylite/src/norm/t/HamacherProduct.cpp
+++ b/fuzzylite/src/norm/t/HamacherProduct.cpp
@@ -1,29 +1,22 @@
/*
- Author: Juan Rada-Vilela, Ph.D.
- Copyright (C) 2010-2014 FuzzyLite Limited
- All rights reserved
+ fuzzylite (R), a fuzzy logic control library in C++.
+ Copyright (C) 2010-2017 FuzzyLite Limited. All rights reserved.
+ Author: Juan Rada-Vilela, Ph.D. <jcrada@fuzzylite.com>
This file is part of fuzzylite.
fuzzylite is free software: you can redistribute it and/or modify it under
- the terms of the GNU Lesser General Public License as published by the Free
- Software Foundation, either version 3 of the License, or (at your option)
- any later version.
+ the terms of the FuzzyLite License included with the software.
- fuzzylite is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with fuzzylite. If not, see <http://www.gnu.org/licenses/>.
-
- fuzzylite™ is a trademark of FuzzyLite Limited.
+ You should have received a copy of the FuzzyLite License along with
+ fuzzylite. If not, see <http://www.fuzzylite.com/license/>.
+ fuzzylite is a registered trademark of FuzzyLite Limited.
*/
#include "fl/norm/t/HamacherProduct.h"
+#include "fl/Operation.h"
namespace fl {
@@ -31,7 +24,12 @@ namespace fl {
return "HamacherProduct";
}
+ Complexity HamacherProduct::complexity() const {
+ return Complexity().arithmetic(5);
+ }
+
scalar HamacherProduct::compute(scalar a, scalar b) const {
+ if (Op::isEq(a + b, 0.0)) return 0.0;
return (a * b) / (a + b - a * b);
}
diff --git a/fuzzylite/src/norm/t/Minimum.cpp b/fuzzylite/src/norm/t/Minimum.cpp
index 34f348f..1a63658 100644
--- a/fuzzylite/src/norm/t/Minimum.cpp
+++ b/fuzzylite/src/norm/t/Minimum.cpp
@@ -1,35 +1,33 @@
/*
- Author: Juan Rada-Vilela, Ph.D.
- Copyright (C) 2010-2014 FuzzyLite Limited
- All rights reserved
+ fuzzylite (R), a fuzzy logic control library in C++.
+ Copyright (C) 2010-2017 FuzzyLite Limited. All rights reserved.
+ Author: Juan Rada-Vilela, Ph.D. <jcrada@fuzzylite.com>
This file is part of fuzzylite.
fuzzylite is free software: you can redistribute it and/or modify it under
- the terms of the GNU Lesser General Public License as published by the Free
- Software Foundation, either version 3 of the License, or (at your option)
- any later version.
+ the terms of the FuzzyLite License included with the software.
- fuzzylite is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with fuzzylite. If not, see <http://www.gnu.org/licenses/>.
-
- fuzzylite™ is a trademark of FuzzyLite Limited.
+ You should have received a copy of the FuzzyLite License along with
+ fuzzylite. If not, see <http://www.fuzzylite.com/license/>.
+ fuzzylite is a registered trademark of FuzzyLite Limited.
*/
#include "fl/norm/t/Minimum.h"
+#include "fl/Operation.h"
+
namespace fl {
std::string Minimum::className() const {
return "Minimum";
}
+ Complexity Minimum::complexity() const {
+ return Complexity().function(1);
+ }
+
scalar Minimum::compute(scalar a, scalar b) const {
return Op::min(a, b);
}
diff --git a/fuzzylite/src/norm/t/NilpotentMinimum.cpp b/fuzzylite/src/norm/t/NilpotentMinimum.cpp
index b52a2fc..7ab906b 100644
--- a/fuzzylite/src/norm/t/NilpotentMinimum.cpp
+++ b/fuzzylite/src/norm/t/NilpotentMinimum.cpp
@@ -1,35 +1,33 @@
/*
- Author: Juan Rada-Vilela, Ph.D.
- Copyright (C) 2010-2014 FuzzyLite Limited
- All rights reserved
+ fuzzylite (R), a fuzzy logic control library in C++.
+ Copyright (C) 2010-2017 FuzzyLite Limited. All rights reserved.
+ Author: Juan Rada-Vilela, Ph.D. <jcrada@fuzzylite.com>
This file is part of fuzzylite.
fuzzylite is free software: you can redistribute it and/or modify it under
- the terms of the GNU Lesser General Public License as published by the Free
- Software Foundation, either version 3 of the License, or (at your option)
- any later version.
+ the terms of the FuzzyLite License included with the software.
- fuzzylite is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with fuzzylite. If not, see <http://www.gnu.org/licenses/>.
-
- fuzzylite™ is a trademark of FuzzyLite Limited.
+ You should have received a copy of the FuzzyLite License along with
+ fuzzylite. If not, see <http://www.fuzzylite.com/license/>.
+ fuzzylite is a registered trademark of FuzzyLite Limited.
*/
#include "fl/norm/t/NilpotentMinimum.h"
+#include "fl/Operation.h"
+
namespace fl {
std::string NilpotentMinimum::className() const {
return "NilpotentMinimum";
}
+ Complexity NilpotentMinimum::complexity() const {
+ return Complexity().comparison(1).arithmetic(1).function(1);
+ }
+
scalar NilpotentMinimum::compute(scalar a, scalar b) const {
if (Op::isGt(a + b, 1.0)) {
return Op::min(a, b);
@@ -47,4 +45,3 @@ namespace fl {
}
-
diff --git a/fuzzylite/src/norm/t/TNormFunction.cpp b/fuzzylite/src/norm/t/TNormFunction.cpp
new file mode 100644
index 0000000..1e0563e
--- /dev/null
+++ b/fuzzylite/src/norm/t/TNormFunction.cpp
@@ -0,0 +1,66 @@
+/*
+ fuzzylite (R), a fuzzy logic control library in C++.
+ Copyright (C) 2010-2017 FuzzyLite Limited. All rights reserved.
+ Author: Juan Rada-Vilela, Ph.D. <jcrada@fuzzylite.com>
+
+ This file is part of fuzzylite.
+
+ fuzzylite is free software: you can redistribute it and/or modify it under
+ the terms of the FuzzyLite License included with the software.
+
+ You should have received a copy of the FuzzyLite License along with
+ fuzzylite. If not, see <http://www.fuzzylite.com/license/>.
+
+ fuzzylite is a registered trademark of FuzzyLite Limited.
+ */
+
+#include "fl/norm/t/TNormFunction.h"
+
+namespace fl {
+
+ TNormFunction::TNormFunction(const std::string& formula) : TNorm() {
+ _function.variables["a"] = fl::nan;
+ _function.variables["b"] = fl::nan;
+ if (not formula.empty()) {
+ _function.load(formula);
+ }
+ }
+
+ std::string TNormFunction::className() const {
+ return "TNormFunction";
+ }
+
+ Complexity TNormFunction::complexity() const {
+ if (_function.root())
+ return _function.complexity().function(2 * std::log(scalar(_function.variables.size())));
+ return _function.complexity();
+ }
+
+ scalar TNormFunction::compute(scalar a, scalar b) const {
+ _function.variables["a"] = a;
+ _function.variables["b"] = b;
+ return _function.evaluate();
+ }
+
+ Function& TNormFunction::function() {
+ return this->_function;
+ }
+
+ void TNormFunction::setFormula(const std::string& formula) {
+ this->_function.load(formula);
+ }
+
+ std::string TNormFunction::getFormula() const {
+ return _function.getFormula();
+ }
+
+ TNormFunction* TNormFunction::clone() const {
+ return new TNormFunction(*this);
+ }
+
+ TNorm* TNormFunction::constructor() {
+ return new TNormFunction;
+ }
+
+
+}