- Main Page
- Tutorials
- Functions
- Release Notes
- Examples

dim4.hpp
Go to the documentation of this file.
1 /*******************************************************
2 * Copyright (c) 2014, ArrayFire
3 * All rights reserved.
4 *
5 * This file is distributed under 3-clause BSD license.
6 * The complete license agreement can be obtained at:
7 * http://arrayfire.com/licenses/BSD-3-Clause
8 ********************************************************/
9
10 #pragma once
11
12 #ifdef __cplusplus
13
14 #include <ostream>
15 #include <istream>
16 #include <vector>
17 #if __cplusplus > 199711L // Necessary for NVCC
18 //#include <initializer_list>
19 #endif
20 #include <af/defines.h>
21 #include <af/seq.h>
22
23
24 namespace af
25 {
26 class AFAPI dim4
27 {
28 public:
29 dim_t dims[4]; //FIXME: Make this C compatiable
30 dim4(); //deleted
31 public:
32 #if __cplusplus > 199711L
33 //dim4(std::initializer_list<dim_t> dim_vals);
34 #endif
35 dim4( dim_t first,
36 dim_t second = 1,
37 dim_t third = 1,
38 dim_t fourth = 1);
39 dim4(const dim4& other);
40 dim4(const unsigned ndims, const dim_t * const dims);
41 dim_t elements();
42 dim_t elements() const;
43 dim_t ndims();
44 dim_t ndims() const;
45 bool operator==(const dim4& other) const;
46 bool operator!=(const dim4& other) const;
47 dim4& operator*=(const dim4& other);
48 dim4& operator+=(const dim4& other);
49 dim4& operator-=(const dim4& other);
50 dim_t& operator[](const unsigned dim);
51 const dim_t& operator[](const unsigned dim) const;
52 dim_t* get() { return dims; }
53 const dim_t* get() const { return dims; }
54 };
55
56 AFAPI dim4 operator+(const dim4& first, const dim4& second);
57 AFAPI dim4 operator-(const dim4& first, const dim4& second);
58 AFAPI dim4 operator*(const dim4& first, const dim4& second);
59
60 static inline
61 std::ostream&
62 operator<<(std::ostream& ostr, const dim4& dims)
63 {
64 ostr << dims[0] << " "
65 << dims[1] << " "
66 << dims[2] << " "
67 << dims[3];
68 return ostr;
69 }
70
71 static inline
72 std::istream&
73 operator>>(std::istream& istr, dim4& dims)
74 {
75 istr >> dims[0]
76 >> dims[1]
77 >> dims[2]
78 >> dims[3];
79 return istr;
80 }
81
82 AFAPI bool isSpan(const af_seq &seq);
83
84 AFAPI size_t seqElements(const af_seq &seq);
85
86 AFAPI dim_t calcDim(const af_seq &seq, const dim_t &parentDim);
87 }
88
89 #endif
af::isSpan
AFAPI bool isSpan(const af_seq &seq)
af
Definition: algorithm.h:14
seq.h
af::operator==
AFAPI array operator==(const array &lhs, const array &rhs)
Performs an equality operation on two arrays or an array and a value.
af::operator*
AFAPI array operator*(const array &lhs, const array &rhs)
Multiplies two arrays or an array and a value.
af::operator>>
AFAPI array operator>>(const array &lhs, const array &rhs)
Performs an right shift operation on two arrays or an array and a value.
defines.h
af::calcDim
AFAPI dim_t calcDim(const af_seq &seq, const dim_t &parentDim)
dim_t
long long dim_t
Definition: defines.h:50
af::operator!=
AFAPI array operator!=(const array &lhs, const array &rhs)
Performs an inequality operation on two arrays or an array and a value.
AFAPI
#define AFAPI
Definition: defines.h:31
af::operator<<
AFAPI array operator<<(const array &lhs, const array &rhs)
Performs an left shift operation on two arrays or an array and a value.
af_seq
Definition: seq.h:13
af::seqElements
AFAPI size_t seqElements(const af_seq &seq)
af::operator-
AFAPI array operator-(const array &lhs, const array &rhs)
Subtracts two arrays or an array and a value.
af::dim4
Definition: dim4.hpp:26
af::operator+
AFAPI array operator+(const array &lhs, const array &rhs)
Adds two arrays or an array and a value.