|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- #ifndef CAPPEDSTORAGE_H
- #define CAPPEDSTORAGE_H
-
- #include <vector>
- #include <map>
- #include <string>
- #include <eigen3/Eigen/Core>
- #include <chrono>
- #include <iostream>
- #include <mutex>
- #include <memory>
- namespace c = std::chrono;
-
- //Class for one dimensional double values
- class CappedStorage
- {
- private:
- //Stored values
- Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> X;
- Eigen::Matrix<double, Eigen::Dynamic, 1> y;
-
- std::unique_ptr<std::mutex> accessMtx;
-
- //If set, storage is extended by bias column (X(:, 1))
- //to perform ML Algorithms
- const bool biased;
-
- public:
- CappedStorage(bool _biased);
-
- void store(const std::vector<uint16_t> &d);
-
- long size() const{ return X.rows(); };
-
- void clear();
-
- Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>& getX(){return X;}
- Eigen::Matrix<double, Eigen::Dynamic, 1>& getY(){return y;}
- long long getN(){return X.cols();}
- long long getM(){return X.rows();}
-
- friend std::ostream &operator<<(std::ostream& os, const CappedStorage& c);
- void lock();
- void unlock();
- };
-
-
-
- #endif // CAPPEDSTORAGE_H
|