Linear.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. Author: Juan Rada-Vilela, Ph.D.
  3. Copyright (C) 2010-2014 FuzzyLite Limited
  4. All rights reserved
  5. This file is part of fuzzylite.
  6. fuzzylite is free software: you can redistribute it and/or modify it under
  7. the terms of the GNU Lesser General Public License as published by the Free
  8. Software Foundation, either version 3 of the License, or (at your option)
  9. any later version.
  10. fuzzylite is distributed in the hope that it will be useful, but WITHOUT
  11. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
  13. for more details.
  14. You should have received a copy of the GNU Lesser General Public License
  15. along with fuzzylite. If not, see <http://www.gnu.org/licenses/>.
  16. fuzzylite™ is a trademark of FuzzyLite Limited.
  17. */
  18. #ifndef FL_LINEAR_H
  19. #define FL_LINEAR_H
  20. #include "fl/term/Term.h"
  21. namespace fl {
  22. class Engine;
  23. class FL_API Linear : public Term {
  24. protected:
  25. std::vector<scalar> _coefficients;
  26. const Engine* _engine;
  27. public:
  28. Linear(const std::string& name = "",
  29. const std::vector<scalar>& coefficients = std::vector<scalar>(),
  30. const Engine* engine = fl::null);
  31. virtual ~Linear() FL_IOVERRIDE;
  32. FL_DEFAULT_COPY_AND_MOVE(Linear)
  33. virtual std::string className() const FL_IOVERRIDE;
  34. virtual std::string parameters() const FL_IOVERRIDE;
  35. virtual void configure(const std::string& parameters) FL_IOVERRIDE;
  36. virtual scalar membership(scalar x) const FL_IOVERRIDE;
  37. virtual void set(const std::vector<scalar>& coeffs, const Engine* engine);
  38. virtual void setCoefficients(const std::vector<scalar>& coeffs);
  39. virtual const std::vector<scalar>& coefficients() const;
  40. virtual std::vector<scalar>& coefficients();
  41. virtual void setEngine(const Engine* engine);
  42. virtual const Engine* getEngine() const;
  43. virtual Linear* clone() const FL_IOVERRIDE;
  44. static Term* constructor();
  45. //Warning: this method is unsafe, make sure you use it correctly.
  46. template <typename T>
  47. static Linear* create(const std::string& name, const Engine* engine,
  48. T firstCoefficient, ...); // throw (fl::Exception);
  49. };
  50. }
  51. #endif /* FL_LINEAR_H */