seq is used to create seq for indexing af::array More...

#include <seq.h>

Public Member Functions

 seq (double length=0)
 Creates a sequence of size length as [0, 1, 2..., length - 1]. More...
 
 ~seq ()
 Destructor. More...
 
 seq (double begin, double end, double step=1)
 Creates a sequence starting at begin, ending at or before end (inclusive) with increments as step. More...
 
 seq (seq afs, bool is_gfor)
 Copy constructor. More...
 
 seq (const af_seq &s_)
 Create a seq object from an af_seq struct. More...
 
seqoperator= (const af_seq &s)
 Assignment operator to create a new sequence from an af_seq. More...
 
seq operator- ()
 Negation operator creates a sequence with the signs negated. More...
 
seq operator+ (double x)
 Addition operator offsets the begin and end by x. More...
 
seq operator- (double x)
 Subtraction operator offsets the begin and end by x. More...
 
seq operator* (double x)
 Multiplication operator spaces the sequence by a factor x. More...
 
 operator array () const
 Implicit conversion operator from seq to af::array. More...
 

Data Fields

af_seq s
 Get the af_seq C-style struct. More...
 
size_t size
 Get's the length of the sequence. More...
 
bool m_gfor
 Flag for gfor. More...
 

Friends

seq operator+ (double x, seq y)
 
seq operator- (double x, seq y)
 
seq operator* (double x, seq y)
 

Detailed Description

Constructor & Destructor Documentation

seq ( double  length = 0)

Creates a sequence of size length as [0, 1, 2..., length - 1].

The sequence has begin as 0, end as length - 1 and step as 1.

Note
When doing seq(-n), where n is > 0, then the sequence is generated as 0...-n but step remains +1. This is because when such a sequence is used for indexing af::array, then -n represents n elements from the end. That is, seq(-2) will imply indexing an array 0...dimSize - 2.
// [begin, end, step]
seq a(10); // [0, 9, 1] => 0, 1, 2....9
Parameters
[in]lengthis the size of the seq to be created.
~seq ( )

Destructor.

seq ( double  begin,
double  end,
double  step = 1 
)

Creates a sequence starting at begin, ending at or before end (inclusive) with increments as step.

The sequence will be [begin, begin + step, begin + 2 * step...., begin + n * step] where the begin + n * step <= end.

// [begin, end, step]
seq a(10, 20); // [10, 20, 1] => 10, 11, 12....20
seq b(10, 20, 2); // [10, 20, 2] => 10, 12, 14....20
seq c(-5, 5); // [-5, 5, 1] => -5, -4, -3....0, 1....5
seq d(-5, -15, -1); // [-5,-15, -1] => -5, -6, -7....-15
seq e(-15, -5, 1); // [-15, -5, 1] => -15, -14, -13....-5
Parameters
[in]beginis the start of the sequence
[in]endis the maximum value a sequence can take (inclusive)
[in]stepis the increment or decrement size (default is 1)
seq ( seq  afs,
bool  is_gfor 
)

Copy constructor.

Creates a copy seq from another sequence.

Parameters
[in]afsseqence to be copies
[in]is_gforis the gfor flag
seq ( const af_seq s_)

Create a seq object from an af_seq struct.

Parameters
[in]s_is the af_seq struct

Member Function Documentation

operator array ( ) const

Implicit conversion operator from seq to af::array.

Convertes a seq object into an af::array object. The contents of the af:array will be the explicit values from the seq.

Note
Do not use this to create arrays of sequences. Use range.
// [begin, end, step]
seq s(10, 20, 2); // [10, 20, 2] => 10, 12, 14....20
array arr = s;
af_print(arr); // 10 12 14 16 18 20
seq operator* ( double  x)
inline

Multiplication operator spaces the sequence by a factor x.

begin is changed to begin * x end is changed to end * x step is changed to step * x

// [begin, end, step]
seq a(10, 20, 2); // [10, 20, 2] => 10, 12, 14....20
seq b(-5, 5); // [-5, 5, 1] => -5, -4, -3....0, 1....5
seq c = a * 3; // [30, 60, 6] => 30, 36, 42....60
seq d = b * 3; // [-15, 15, 3] => -15, -12, -9....0, 3....15
seq e = a * 0.5; // [5, 10, 1] => 5, 6, 7....10
seq operator+ ( double  x)
inline

Addition operator offsets the begin and end by x.

There is no change in step.

begin is changed to begin + x end is changed to end + x

// [begin, end, step]
seq a(2, 20, 2); // [2, 20, 2] => 2, 4, 6....20
seq b = a + 3; // [5, 23, 2] => 5, 7, 9....23
seq operator- ( )
inline

Negation operator creates a sequence with the signs negated.

begin is changed to -begin end is changed to -end step is changed to -step

// [begin, end, step]
seq a(1, 10); // [ 1, 10, 1] => 1, 2, 3....10
seq b = -a; // [-1,-10,-1] => -1, -2, -3...-10
seq operator- ( double  x)
inline

Subtraction operator offsets the begin and end by x.

There is no change in step.

begin is changed to begin - x end is changed to end - x

// [begin, end, step]
seq a(10, 20, 2); // [10, 20, 2] => 10, 12, 14....20
seq b(2, 10); // [ 2, 10, 1] => 2, 3, 4....10
seq c = a - 3; // [ 7, 17, 2] => 7, 9, 11....17
seq d = b - 3; // [-1, 7, 2] => -1, 1, 3....7
seq& operator= ( const af_seq s)

Assignment operator to create a new sequence from an af_seq.

This operator creates a new sequence using the begin, end and step from the input sequence.

Parameters
[in]sis the input sequence

Friends And Related Function Documentation

seq operator* ( double  x,
seq  y 
)
friend
seq operator+ ( double  x,
seq  y 
)
friend
seq operator- ( double  x,
seq  y 
)
friend

Field Documentation

bool m_gfor

Flag for gfor.

af_seq s

Get the af_seq C-style struct.

size_t size

Get's the length of the sequence.


The documentation for this class was generated from the following file: