-
Notifications
You must be signed in to change notification settings - Fork 6
/
DB.h
69 lines (57 loc) · 1.79 KB
/
DB.h
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
/*
* DB.h
* TTree
*
* Created by Vincent Botta on 17/12/08.
* Copyright 2008 University of Liège. All rights reserved.
*
*/
#ifndef __DB__
#define __DB__
#include <iostream>
#include <vector>
#include <cstdio>
#include "ScoreInfo.h"
#define NUMERICAL 0
#define SNP 1
#define REPTYPE short int
#define SETREP unsigned int
class DB {
private:
unsigned int nbobject;
unsigned int nbclass;
std::vector<double> weight;
unsigned int type;
public:
DB();
DB(int nbo,int nba);
~DB();
void setType(unsigned int t = NUMERICAL) { type = t; }
unsigned int getType() const { return type; }
double getWeight(unsigned int i) const;
void setWeight(std::vector<double> w);
void setWeight(double w = 1.0);
void initWeight(unsigned int size, double w = 1.0);
std::vector<SETREP> selectAll(bool att = false) const;
std::vector<SETREP> select(int start,int end, bool att = false) const;
std::vector<unsigned int> selectAllAtt() const;
std::vector<unsigned int> selectAtt(int start,int end) const;
REPTYPE getOutput(unsigned int o) const;
REPTYPE getAttVal(unsigned int o, unsigned int a) const;
void setNbObject(unsigned int nbo);
void setNbAtt(unsigned int nba);
unsigned int getNbAtt() const;
void getLRSet(ScoreInfo &si, std::vector<unsigned int> &set,
std::vector<unsigned int> &left, std::vector<unsigned int> &right);
unsigned int getNbClass() const { return nbclass ; }
protected:
void print(FILE* out = stdout, bool all = false) const;
unsigned int nbatt;
std::vector<REPTYPE> output;
std::vector<REPTYPE> att;
void setNbClass(int i = 0);
};
inline double DB::getWeight(unsigned int i) const {return weight[i];}
inline REPTYPE DB::getOutput(unsigned int o) const {return output[o];}
inline REPTYPE DB::getAttVal(unsigned int o, unsigned int a) const {return att[o*nbatt+a];}
#endif