-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDimensions.hpp
63 lines (44 loc) · 1.25 KB
/
Dimensions.hpp
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
#ifndef DIMENSIONS_HPP
#define DIMENSIONS_HPP
#include <vector>
#include <cstdarg>
#include <cassert>
#include <string>
#include <numeric>
#include <sstream>
#include <boost/shared_ptr.hpp>
namespace J {
using std::vector;
using std::string;
using boost::shared_ptr;
using std::stringstream;
class Dimensions {
typedef vector<int>::iterator iter;
shared_ptr<vector<int> > dims;
iter begin_iter;
iter end_iter;
int rank;
public:
Dimensions(int rank, ...);
Dimensions();
Dimensions(shared_ptr<vector<int> > dims);
Dimensions(shared_ptr<vector<int> > dims, iter begin, iter end);
iter begin() const { return begin_iter; }
iter end() const { return end_iter; }
int get_rank() const { return rank; }
string to_string() const;
bool operator!=(const Dimensions& d) const {
return !(*this == d);
}
bool operator==(const Dimensions& d) const;
int operator[](int n) const;
Dimensions suffix(int n) const;
Dimensions prefix(int n) const;
bool prefix_match(const Dimensions &d) const;
bool suffix_match(const Dimensions &d) const;
int number_of_elems() const;
Dimensions operator+(const Dimensions &d) const;
friend std::ostream& operator<<(std::ostream& os, const Dimensions& d);
};
}
#endif