-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdistancematrix.h
40 lines (34 loc) · 1.1 KB
/
distancematrix.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
#ifndef DISTANCEMATRIX_H
#define DISTANCEMATRIX_H
#include <string>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
// triangular matrix, with identity data
class distancematrix {
private:
bool valid = false;
unsigned int size;
int fd;
long double *vec;
size_t allocsize;
unsigned int vecsize;
const mode_t filemode = S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH;
unsigned int sub(const unsigned int i, const unsigned int j) const;
void checkij(const unsigned int i, const unsigned int j) const;
public:
distancematrix(const unsigned int sizep, const std::string filenamep);
distancematrix(const std::string filenamep);
distancematrix(void);
void init(const unsigned int sizep, const std::string filenamep);
void init(const std::string filenamep);
~distancematrix();
long double get(const unsigned int, const unsigned int) const;
void set(const unsigned int, const unsigned int, const long double);
void checksanity();
void print(void) const;
unsigned int get_size() const {
return size;
};
};
#endif // DISTANCEMATRIX_H