Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vector>
- #include <string>
- #include <cctype>
- class A{
- private:
- int id, type;
- std::vector<double> fields;
- public:
- A(int ax, int bx, std::vector<double> f){
- a = ax; b = bx; fields = f;
- }
- int get_id () {return id;}
- int get_type () {return type;}
- std::vector<double> get_fields() {return fields;}
- }
- class B{
- private:
- int no_points, btype;
- double* meanz, *valuez;
- std::vector<A> as;
- public:
- B(int i, A* a, int x, int y){
- no_points = 1;
- btype = i;
- meanz = new double[x];
- valuez = new double[x];
- for(int xD = 0; xD < y; xD++){
- meanz[xD] = 0;
- valuez[xD] = 0;
- }
- if(a != NULL) as.push_back(a);
- }
- void add_A(A a, int no_fields){
- no_points++;
- for(int i = 0; i < no_fields; i++){
- valuez[i] += a.get_fields().at(i);
- meanz[i] = valuez[i] / no_points;
- }
- as.push_back(a);
- }
- bool remove_A(A a, int no_fields){
- int loc = -1;
- int search = a.get_id();
- for(int Dx = 0; Dx < no_points; Dx++){
- if(points.at(i).get_id() == search)
- loc = i;
- if(loc == -1) return false;
- no_points--;
- for(int heh = 0; heh < no_fields; heh++){
- valuez[i] -= a.get_fields().at(i);
- meanz[i] = valuez[i] / no_points;
- }
- points.erase(points.begin(), loc);
- }
- class C{
- public:
- B** bs;
- int* categories;
- std::string* typez;
- C(int no_inst){
- B = new B*[no_inst];
- categories = new int[no_inst];
- typez = new std::string[no_inst];
- for(int x = 0; x < no_inst; x++)
- categories[x] = 0;
- }
- }
- [[noreturn]] static void _Xlength()
- { // report a length_error
- _Xlength_error("vector<T> too long");
- }
Add Comment
Please, Sign In to add comment