seq.h Source File

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

seq.h
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 #include <af/defines.h>
12
13 typedef struct af_seq {
14 double begin, end;
15 double step;
16 } af_seq;
17
18 static const af_seq af_span = {1, 1, 0};
19
20 #ifdef __cplusplus
21 namespace af
22 {
23 class array;
24
25 class AFAPI seq
26 {
27 public:
28 af_seq s;
29 size_t size;
30 bool m_gfor;
31
32 seq(double = 0);
33 ~seq();
34
35 // begin, end, step
36 seq(double begin, double end, double step = 1);
37
38 seq(seq afs, bool is_gfor);
39
40 seq(const af_seq& s_);
41
42 seq& operator=(const af_seq& s);
43
44 inline seq operator-() { return seq(-s.begin, -s.end, -s.step); }
45
46 inline seq operator+(double x) { return seq(s.begin + x, s.end + x, s.step); }
47
48 inline seq operator-(double x) { return seq(s.begin - x, s.end - x, s.step); }
49
50 inline seq operator*(double x) { return seq(s.begin * x, s.end * x, s.step * x); }
51
52 friend inline seq operator+(double x, seq y) { return y + x; }
53
54 friend inline seq operator-(double x, seq y) { return -y + x; }
55
56 friend inline seq operator*(double x, seq y) { return y * x; }
57
58 operator array() const;
59
60 private:
61 void init(double begin, double end, double step);
62 };
63
64 extern AFAPI int end;
65 extern AFAPI seq span;
66
67 }
68 #endif
69
70 #ifdef __cplusplus
71 extern "C" {
72 #endif
73 AFAPI af_seq af_make_seq(double begin, double end, double step);
74
75 #ifdef __cplusplus
76 }
77 #endif
af_seq::step
double step
Definition: seq.h:15
af
Definition: algorithm.h:14
af::seq::operator*
seq operator*(double x)
Definition: seq.h:50
af::seq::operator-
seq operator-()
Definition: seq.h:44
af_seq
struct af_seq af_seq
af::seq::size
size_t size
Definition: seq.h:29
af_seq::begin
double begin
Definition: seq.h:14
af::seq::operator*
friend seq operator*(double x, seq y)
Definition: seq.h:56
af_seq::end
double end
Definition: seq.h:14
af::seq::m_gfor
bool m_gfor
Definition: seq.h:30
af_make_seq
AFAPI af_seq af_make_seq(double begin, double end, double step)
af::span
AFAPI seq span
af::seq
Definition: seq.h:25
defines.h
af::seq::operator-
seq operator-(double x)
Definition: seq.h:48
AFAPI
#define AFAPI
Definition: defines.h:31
af::seq::operator+
friend seq operator+(double x, seq y)
Definition: seq.h:52
af_seq
Definition: seq.h:13
af::seq::s
af_seq s
Definition: seq.h:28
af::seq::operator-
friend seq operator-(double x, seq y)
Definition: seq.h:54
afcl::array
static af::array array(af::dim4 idims, cl_mem buf, af::dtype type, bool retain=false)
Create an af::array object from an OpenCL cl_mem buffer.
Definition: opencl.h:161
af::end
AFAPI int end
af_span
static const af_seq af_span
Definition: seq.h:18
af::seq::operator+
seq operator+(double x)
Definition: seq.h:46