aboutsummaryrefslogtreecommitdiffstats
path: root/data_sets/default_data_set.hpp
blob: 696403ef5c3daaa9ce7bdf5f9aeb11ad7b37a3c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/**
   \file default_data_set.hpp
   \brief default implement of data set
   \author Junhua Gu
 */

#ifndef DEFAULT_DATA_SET
#define DEFAULT_DATA_SET
#define OPT_HEADER
#include "core/fitter.hpp"
#include <vector>


namespace opt_utilities
{

  /**
     \brief default implement of the data set
     \tparam Ty type of y
     \tparam Tx type of x
   */
  template <typename Ty,typename Tx>
  class default_data_set
    :public data_set<Ty,Tx>
  {
    //  private:
  public:
    std::vector<data<Ty,Tx> > data_vec;

    data_set<Ty,Tx>* do_clone()const
    {
      return new default_data_set<Ty,Tx>(*this);
    }


    const data<Ty,Tx>& do_get_data(size_t i)const
    {
      return data_vec.at(i);
    }

    size_t do_size()const
    {
      return data_vec.size();
    }

    void do_add_data(const data<Ty,Tx>& d)
    {
      data_vec.push_back(d);
    }

    void do_clear()
    {
      data_vec.clear();
    }

  public:
    default_data_set()
    {}

    default_data_set(const default_data_set<Ty,Tx>& rhs)
      :data_vec(rhs.data_vec)
    {}

    default_data_set(const data_set<Ty,Tx>& rhs)
    {
      data_vec.resize(rhs.size());
      for(size_t i=0;i<data_vec.size();++i)
	{
	  data_vec[i]=(rhs.get_data(i));
	}
    }

    default_data_set& operator=(const default_data_set<Ty,Tx>& rhs)
    {
      data_vec=rhs.data_vec;
      return *this;
    }

    default_data_set& operator=(const data_set<Ty,Tx>& rhs)
    {
      data_vec.resize(rhs.size());
      for(int i=0;i<data_vec.size();++i)
	{
	  data_vec[i](rhs.get_data(i));
	}
      return *this;
    }


  };
}

#endif
//EOF