forked from arrayfire/arrayfire
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdim4.hpp
More file actions
83 lines (71 loc) · 1.98 KB
/
Copy pathdim4.hpp
File metadata and controls
83 lines (71 loc) · 1.98 KB
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
/*******************************************************
* Copyright (c) 2014, ArrayFire
* All rights reserved.
*
* This file is distributed under 3-clause BSD license.
* The complete license agreement can be obtained at:
* http://arrayfire.com/licenses/BSD-3-Clause
********************************************************/
#pragma once
#ifdef __cplusplus
#include <ostream>
#include <istream>
#include <vector>
#include <af/defines.h>
#include <af/seq.h>
namespace af
{
class AFAPI dim4
{
public:
dim_t dims[4]; //FIXME: Make this C compatible
dim4(); //deleted
public:
dim4( dim_t first,
dim_t second = 1,
dim_t third = 1,
dim_t fourth = 1);
dim4(const dim4& other);
dim4(const unsigned ndims, const dim_t * const dims);
dim_t elements();
dim_t elements() const;
dim_t ndims();
dim_t ndims() const;
bool operator==(const dim4& other) const;
bool operator!=(const dim4& other) const;
dim4& operator*=(const dim4& other);
dim4& operator+=(const dim4& other);
dim4& operator-=(const dim4& other);
dim_t& operator[](const unsigned dim);
const dim_t& operator[](const unsigned dim) const;
dim_t* get() { return dims; }
const dim_t* get() const { return dims; }
};
AFAPI dim4 operator+(const dim4& first, const dim4& second);
AFAPI dim4 operator-(const dim4& first, const dim4& second);
AFAPI dim4 operator*(const dim4& first, const dim4& second);
static inline
std::ostream&
operator<<(std::ostream& ostr, const dim4& dims)
{
ostr << dims[0] << " "
<< dims[1] << " "
<< dims[2] << " "
<< dims[3];
return ostr;
}
static inline
std::istream&
operator>>(std::istream& istr, dim4& dims)
{
istr >> dims[0]
>> dims[1]
>> dims[2]
>> dims[3];
return istr;
}
AFAPI bool isSpan(const af_seq &seq);
AFAPI size_t seqElements(const af_seq &seq);
AFAPI dim_t calcDim(const af_seq &seq, const dim_t &parentDim);
}
#endif