My Project
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 
20 typedef struct af_seq {
22  double begin;
23 
25  double end;
26 
28  double step;
29 } af_seq;
30 
31 static const af_seq af_span = {1, 1, 0};
32 
33 #ifdef __cplusplus
34 namespace af
35 {
36 class array;
37 
45 class AFAPI seq
46 {
47 public:
51  af_seq s;
52 
56  size_t size;
57 
61  bool m_gfor;
62 
80  seq(double length = 0);
81 
85  ~seq();
86 
107  seq(double begin, double end, double step = 1);
108 
117  seq(seq afs, bool is_gfor);
118 
124  seq(const af_seq& s_);
125 
134  seq& operator=(const af_seq& s);
135 
149  inline seq operator-() { return seq(-s.begin, -s.end, -s.step); }
150 
164  inline seq operator+(double x) { return seq(s.begin + x, s.end + x, s.step); }
165 
181  inline seq operator-(double x) { return seq(s.begin - x, s.end - x, s.step); }
182 
199  inline seq operator*(double x) { return seq(s.begin * x, s.end * x, s.step * x); }
200 
201  friend inline seq operator+(double x, seq y) { return y + x; }
202 
203  friend inline seq operator-(double x, seq y) { return -y + x; }
204 
205  friend inline seq operator*(double x, seq y) { return y * x; }
206 
222  operator array() const;
223 
224  private:
225  void init(double begin, double end, double step);
226 };
227 
228 extern AFAPI int end;
229 extern AFAPI seq span;
230 
231 }
232 #endif
233 
234 #ifdef __cplusplus
235 extern "C" {
236 #endif
237 AFAPI af_seq af_make_seq(double begin, double end, double step);
238 
239 #ifdef __cplusplus
240 }
241 #endif
af::seq
seq is used to create seq for indexing af::array
Definition: seq.h:44
AFAPI
#define AFAPI
Definition: defines.h:30
af
Definition: algorithm.h:13
af_seq::end
double end
End position of the sequence (inclusive)
Definition: seq.h:24
af_make_seq
AFAPI af_seq af_make_seq(double begin, double end, double step)
af::operator-
AFAPI array operator-(const array &lhs, const array &rhs)
Subtracts two arrays or an array and a value.
af_seq::begin
double begin
Start position of the sequence.
Definition: seq.h:21
af_span
static const af_seq af_span
Definition: seq.h:30
af::span
AFAPI seq span
af::operator*
AFAPI array operator*(const array &lhs, const array &rhs)
Multiplies two arrays or an array and a value.
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:328
af_seq
struct af_seq af_seq
af::operator+
AFAPI array operator+(const array &lhs, const array &rhs)
Adds two arrays or an array and a value.
af_seq::step
double step
Step size between sequence values.
Definition: seq.h:27
defines.h
af::end
AFAPI int end
af_seq
C-style struct to creating sequences for indexing.
Definition: seq.h:19