My Project
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
24namespace af
25{
27{
28 public:
29 dim_t dims[4]; //FIXME: Make this C compatiable
30 dim4(); //deleted
31public:
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);
42 dim_t elements() const;
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
56AFAPI dim4 operator+(const dim4& first, const dim4& second);
57AFAPI dim4 operator-(const dim4& first, const dim4& second);
58AFAPI dim4 operator*(const dim4& first, const dim4& second);
59
60static inline
61std::ostream&
62operator<<(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
71static inline
72std::istream&
73operator>>(std::istream& istr, dim4& dims)
74{
75 istr >> dims[0]
76 >> dims[1]
77 >> dims[2]
78 >> dims[3];
79 return istr;
80}
81
82AFAPI bool isSpan(const af_seq &seq);
83
84AFAPI size_t seqElements(const af_seq &seq);
85
86AFAPI dim_t calcDim(const af_seq &seq, const dim_t &parentDim);
87}
88
89#endif
Definition: dim4.hpp:27
dim4(const unsigned ndims, const dim_t *const dims)
dim4 & operator-=(const dim4 &other)
const dim_t & operator[](const unsigned dim) const
dim_t & operator[](const unsigned dim)
const dim_t * get() const
Definition: dim4.hpp:53
dim4(const dim4 &other)
dim4 & operator*=(const dim4 &other)
dim_t elements()
dim_t ndims()
bool operator!=(const dim4 &other) const
dim4(dim_t first, dim_t second=1, dim_t third=1, dim_t fourth=1)
dim_t elements() const
bool operator==(const dim4 &other) const
dim4 & operator+=(const dim4 &other)
dim_t ndims() const
dim_t * get()
Definition: dim4.hpp:52
seq is used to create seq for indexing af::array
Definition: seq.h:46
long long dim_t
Definition: defines.h:50
#define AFAPI
Definition: defines.h:31
AFAPI array operator+(const array &lhs, const array &rhs)
Adds two arrays or an array and a value.
AFAPI array operator*(const array &lhs, const array &rhs)
Multiplies two arrays or an array and a value.
AFAPI array operator<<(const array &lhs, const array &rhs)
Performs an left shift operation on two arrays or an array and a value.
AFAPI array operator>>(const array &lhs, const array &rhs)
Performs an right shift operation on two arrays or an array and a value.
AFAPI array operator-(const array &lhs, const array &rhs)
Subtracts two arrays or an array and a value.
Definition: algorithm.h:15
AFAPI dim_t calcDim(const af_seq &seq, const dim_t &parentDim)
AFAPI size_t seqElements(const af_seq &seq)
AFAPI bool isSpan(const af_seq &seq)
C-style struct to creating sequences for indexing.
Definition: seq.h:20