Digitalisierte Elektroverteilung zur permanenten Verbraucherüberwachung
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cappedstorage.h 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #ifndef CAPPEDSTORAGE_H
  2. #define CAPPEDSTORAGE_H
  3. #include <vector>
  4. #include <map>
  5. #include <string>
  6. #include <eigen3/Eigen/Core>
  7. #include <chrono>
  8. #include <iostream>
  9. #include <mutex>
  10. #include <memory>
  11. namespace c = std::chrono;
  12. //Class for one dimensional double values
  13. class CappedStorage
  14. {
  15. private:
  16. //Stored values
  17. Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> X;
  18. Eigen::Matrix<double, Eigen::Dynamic, 1> y;
  19. std::unique_ptr<std::mutex> accessMtx;
  20. //If set, storage is extended by bias column (X(:, 1))
  21. //to perform ML Algorithms
  22. const bool biased;
  23. public:
  24. CappedStorage(bool _biased);
  25. void store(const std::vector<uint16_t> &d);
  26. long size() const{ return X.rows(); };
  27. void clear();
  28. Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>& getX(){return X;}
  29. Eigen::Matrix<double, Eigen::Dynamic, 1>& getY(){return y;}
  30. long long getN(){return X.cols();}
  31. long long getM(){return X.rows();}
  32. friend std::ostream &operator<<(std::ostream& os, const CappedStorage& c);
  33. void lock();
  34. void unlock();
  35. };
  36. #endif // CAPPEDSTORAGE_H