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:
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
double step
Definition: seq.h:15
Definition: algorithm.h:14
seq operator*(double x)
Definition: seq.h:50
seq operator-()
Definition: seq.h:44
struct af_seq af_seq
size_t size
Definition: seq.h:29
double begin
Definition: seq.h:14
friend seq operator*(double x, seq y)
Definition: seq.h:56
double end
Definition: seq.h:14
bool m_gfor
Definition: seq.h:30
AFAPI af_seq af_make_seq(double begin, double end, double step)
AFAPI seq span
Definition: seq.h:25
seq operator-(double x)
Definition: seq.h:48
#define AFAPI
Definition: defines.h:31
friend seq operator+(double x, seq y)
Definition: seq.h:52
Definition: seq.h:13
af_seq s
Definition: seq.h:28
friend seq operator-(double x, seq y)
Definition: seq.h:54
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:105
AFAPI int end
static const af_seq af_span
Definition: seq.h:18
seq operator+(double x)
Definition: seq.h:46