Skip to content

Commit fec7f42

Browse files
committed
STYLE: Minor style changes to indexing structs and classes
1 parent 4d576b2 commit fec7f42

18 files changed

Lines changed: 179 additions & 179 deletions

File tree

include/af/array.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -603,15 +603,15 @@ namespace af
603603
\ingroup index_mat
604604
*/
605605

606-
array::array_proxy operator()(const indexer &s0,
607-
const indexer &s1 = span,
608-
const indexer &s2 = span,
609-
const indexer &s3 = span);
610-
611-
const array::array_proxy operator()(const indexer &s0,
612-
const indexer &s1 = span,
613-
const indexer &s2 = span,
614-
const indexer &s3 = span) const;
606+
array::array_proxy operator()(const index &s0,
607+
const index &s1 = span,
608+
const index &s2 = span,
609+
const index &s3 = span);
610+
611+
const array::array_proxy operator()(const index &s0,
612+
const index &s1 = span,
613+
const index &s2 = span,
614+
const index &s3 = span) const;
615615

616616
array::array_proxy row(int index) const;
617617

include/af/index.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@
1313

1414
typedef struct af_index_t{
1515
// if seq is used for current dimension
16-
// mIsSeq is set to 'true' and mIndexer.seq
17-
// should be used. Otherwise, mIndexer.arr
16+
// isSeq is set to 'true' and idx.seq
17+
// should be used. Otherwise, idx.arr
1818
// should be used.
1919
union {
2020
af_array arr;
2121
af_seq seq;
22-
} mIndexer;
22+
} idx;
2323
// below variable is used to determine if
2424
// the current dimension is indexed using
2525
// af_array or af_seq
26-
bool mIsSeq;
26+
bool isSeq;
2727
bool isBatch;
2828
} af_index_t;
2929

@@ -37,15 +37,15 @@ class dim4;
3737
class array;
3838
class seq;
3939

40-
class AFAPI indexer {
40+
class AFAPI index {
4141
af_index_t impl;
4242
public:
43-
indexer();
43+
index();
4444

45-
indexer(const int idx);
46-
indexer(const af::seq& s0);
47-
indexer(const af_seq& s0);
48-
indexer(const af::array& idx0);
45+
index(const int idx);
46+
index(const af::seq& s0);
47+
index(const af_seq& s0);
48+
index(const af::array& idx0);
4949

5050
bool isspan() const;
5151
const af_index_t& get() const;
@@ -298,12 +298,12 @@ extern "C" {
298298
// generalized indexing function that accepts either af_array or af_seq
299299
// along a dimension to index the input array and create the corresponding
300300
// output array
301-
AFAPI af_err af_index_gen(af_array *out, const af_array in, const dim_type ndims, const af_index_t* indexers);
301+
AFAPI af_err af_index_gen(af_array *out, const af_array in, const dim_type ndims, const af_index_t* indexs);
302302

303303
// generalized indexing function that accepts either af_array or af_seq
304304
// along a dimension to index the input array and create the corresponding
305305
// output array
306-
AFAPI af_err af_assign_gen(af_array *out, const af_array lhs, const dim_type ndims, const af_index_t* indexers, const af_array rhs);
306+
AFAPI af_err af_assign_gen(af_array *out, const af_array lhs, const dim_type ndims, const af_index_t* indexs, const af_array rhs);
307307

308308
#ifdef __cplusplus
309309
}

src/api/c/assign.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -146,39 +146,39 @@ af_err af_assign_seq(af_array *out,
146146
}
147147

148148
template<typename T>
149-
static void genAssign(af_array& out, const af_index_t* indexers, const af_array& rhs)
149+
static void genAssign(af_array& out, const af_index_t* indexs, const af_array& rhs)
150150
{
151-
detail::assign<T>(getWritableArray<T>(out), indexers, getArray<T>(rhs));
151+
detail::assign<T>(getWritableArray<T>(out), indexs, getArray<T>(rhs));
152152
}
153153

154154
af_err af_assign_gen(af_array *out,
155155
const af_array lhs,
156-
const dim_type ndims, const af_index_t* indexers,
156+
const dim_type ndims, const af_index_t* indexs,
157157
const af_array rhs_)
158158
{
159159
af_array output = 0;
160160
af_array rhs = rhs_;
161-
// spanner is sequence indexer used for indexing along the
161+
// spanner is sequence index used for indexing along the
162162
// dimensions after ndims
163163
af_index_t spanner;
164-
spanner.mIndexer.seq = af_span;
165-
spanner.mIsSeq = true;
164+
spanner.idx.seq = af_span;
165+
spanner.isSeq = true;
166166

167167
try {
168168
ARG_ASSERT(2, (ndims>0));
169-
ARG_ASSERT(3, (indexers!=NULL));
169+
ARG_ASSERT(3, (indexs!=NULL));
170170

171171
int track = 0;
172172
vector<af_seq> seqs(4, af_span);
173173
for (dim_type i = 0; i < ndims; i++) {
174-
if (indexers[i].mIsSeq) {
174+
if (indexs[i].isSeq) {
175175
track++;
176-
seqs[i] = indexers[i].mIndexer.seq;
176+
seqs[i] = indexs[i].idx.seq;
177177
}
178178
}
179179

180180
if (track==ndims) {
181-
// all indexers are sequences, redirecting to af_assign
181+
// all indexs are sequences, redirecting to af_assign
182182
return af_assign_seq(out, lhs, ndims, &(seqs.front()), rhs);
183183
}
184184

@@ -201,12 +201,12 @@ af_err af_assign_gen(af_array *out,
201201
ARG_ASSERT(2, (lhsDims.ndims()>=(int)ndims));
202202

203203
dim4 oDims = toDims(seqs, lhsDims);
204-
// if af_array are indexers along any
204+
// if af_array are indexs along any
205205
// particular dimension, set the length of
206206
// that dimension accordingly before any checks
207207
for (dim_type i=0; i<ndims; i++) {
208-
if (!indexers[i].mIsSeq) {
209-
oDims[i] = getInfo(indexers[i].mIndexer.arr).elements();
208+
if (!indexs[i].isSeq) {
209+
oDims[i] = getInfo(indexs[i].idx.arr).elements();
210210
}
211211
}
212212

@@ -231,26 +231,26 @@ af_err af_assign_gen(af_array *out,
231231
}
232232

233233
af_index_t idxrs[4];
234-
// set all dimensions above ndims to spanner indexer
234+
// set all dimensions above ndims to spanner index
235235
for (dim_type i=ndims; i<4; ++i) idxrs[i] = spanner;
236236

237237
for (dim_type i=0; i<ndims; ++i) {
238-
if (!indexers[i].mIsSeq) {
238+
if (!indexs[i].isSeq) {
239239
// check if all af_arrays have atleast one value
240240
// to enable indexing along that dimension
241-
ArrayInfo idxInfo = getInfo(indexers[i].mIndexer.arr);
241+
ArrayInfo idxInfo = getInfo(indexs[i].idx.arr);
242242
af_dtype idxType = idxInfo.getType();
243243

244244
ARG_ASSERT(3, (idxType!=c32));
245245
ARG_ASSERT(3, (idxType!=c64));
246246
ARG_ASSERT(3, (idxType!=b8 ));
247247

248-
idxrs[i].mIndexer.arr = indexers[i].mIndexer.arr;
249-
idxrs[i].mIsSeq = indexers[i].mIsSeq;
248+
idxrs[i].idx.arr = indexs[i].idx.arr;
249+
idxrs[i].isSeq = indexs[i].isSeq;
250250
} else {
251251
// af_seq is being used for this dimension
252-
// just copy the indexer to local variable
253-
idxrs[i] = indexers[i];
252+
// just copy the index to local variable
253+
idxrs[i] = indexs[i];
254254
}
255255
}
256256

src/api/c/index.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -129,54 +129,54 @@ af_array genIndex(const af_array& in, const af_index_t idxrs[])
129129
return getHandle<T>(index<T>(getArray<T>(in), idxrs));
130130
}
131131

132-
af_err af_index_gen(af_array *out, const af_array in, const dim_type ndims, const af_index_t* indexers)
132+
af_err af_index_gen(af_array *out, const af_array in, const dim_type ndims, const af_index_t* indexs)
133133
{
134134
af_array output = 0;
135-
// spanner is sequence indexer used for indexing along the
135+
// spanner is sequence index used for indexing along the
136136
// dimensions after ndims
137137
af_index_t spanner;
138-
spanner.mIndexer.seq = af_span;
139-
spanner.mIsSeq = true;
138+
spanner.idx.seq = af_span;
139+
spanner.isSeq = true;
140140

141141
try {
142142
ARG_ASSERT(2, (ndims>0));
143-
ARG_ASSERT(3, (indexers!=NULL));
143+
ARG_ASSERT(3, (indexs!=NULL));
144144

145145
int track = 0;
146146
af_seq seqs[] = {af_span, af_span, af_span, af_span};
147147
for (dim_type i = 0; i < ndims; i++) {
148-
if (indexers[i].mIsSeq) {
148+
if (indexs[i].isSeq) {
149149
track++;
150-
seqs[i] = indexers[i].mIndexer.seq;
150+
seqs[i] = indexs[i].idx.seq;
151151
}
152152
}
153153

154154
if (track==ndims) {
155-
// all indexers are sequences, redirecting to af_index
155+
// all indexs are sequences, redirecting to af_index
156156
return af_index(out, in, ndims, seqs);
157157
}
158158

159159
af_index_t idxrs[4];
160-
// set all dimensions above ndims to spanner indexer
160+
// set all dimensions above ndims to spanner index
161161
for (dim_type i=ndims; i<4; ++i) idxrs[i] = spanner;
162162

163163
for (dim_type i=0; i<ndims; ++i) {
164-
if (!indexers[i].mIsSeq) {
164+
if (!indexs[i].isSeq) {
165165
// check if all af_arrays have atleast one value
166166
// to enable indexing along that dimension
167-
ArrayInfo idxInfo = getInfo(indexers[i].mIndexer.arr);
167+
ArrayInfo idxInfo = getInfo(indexs[i].idx.arr);
168168
af_dtype idxType = idxInfo.getType();
169169

170170
ARG_ASSERT(3, (idxType!=c32));
171171
ARG_ASSERT(3, (idxType!=c64));
172172
ARG_ASSERT(3, (idxType!=b8 ));
173173

174-
idxrs[i].mIndexer.arr = indexers[i].mIndexer.arr;
175-
idxrs[i].mIsSeq = indexers[i].mIsSeq;
174+
idxrs[i].idx.arr = indexs[i].idx.arr;
175+
idxrs[i].isSeq = indexs[i].isSeq;
176176
} else {
177177
// af_seq is being used for this dimension
178-
// just copy the indexer to local variable
179-
idxrs[i] = indexers[i];
178+
// just copy the index to local variable
179+
idxrs[i] = indexs[i];
180180
}
181181
}
182182

src/api/cpp/array.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ namespace af
4545
try {
4646
af::dim4 odims(1);
4747
for (int i = 0; i < AF_MAX_DIMS; i++) {
48-
if (indices[i].mIsSeq) {
49-
odims[i] = calcDim(indices[i].mIndexer.seq, parentDims[i]);
48+
if (indices[i].isSeq) {
49+
odims[i] = calcDim(indices[i].idx.seq, parentDims[i]);
5050
} else {
5151
dim_type elems = 0;
52-
AF_THROW(af_get_elements(&elems, indices[i].mIndexer.arr));
52+
AF_THROW(af_get_elements(&elems, indices[i].idx.arr));
5353
odims[i] = elems;
5454
}
5555
}
@@ -316,12 +316,12 @@ namespace af
316316
}
317317

318318

319-
array::array_proxy array::operator()(const indexer &s0, const indexer &s1, const indexer &s2, const indexer &s3)
319+
array::array_proxy array::operator()(const index &s0, const index &s1, const index &s2, const index &s3)
320320
{
321321
return const_cast<const array*>(this)->operator()(s0, s1, s2, s3);
322322
}
323323

324-
const array::array_proxy array::operator()(const indexer &s0, const indexer &s1, const indexer &s2, const indexer &s3) const
324+
const array::array_proxy array::operator()(const index &s0, const index &s1, const index &s2, const index &s3) const
325325
{
326326
if(isvector() && s1.isspan()
327327
&& s2.isspan()

src/api/cpp/index.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -106,37 +106,37 @@ array lookup(const array &in, const array &idx, const int dim)
106106
return array(out);
107107
}
108108

109-
indexer::indexer() {
110-
impl.mIndexer.seq = af_span;
111-
impl.mIsSeq = true;
109+
index::index() {
110+
impl.idx.seq = af_span;
111+
impl.isSeq = true;
112112
impl.isBatch = false;
113113
}
114114

115-
indexer::indexer(const int idx) {
116-
impl.mIndexer.seq = af_make_seq(idx, idx, 1);
117-
impl.mIsSeq = true;
115+
index::index(const int idx) {
116+
impl.idx.seq = af_make_seq(idx, idx, 1);
117+
impl.isSeq = true;
118118
impl.isBatch = false;
119119
}
120120

121-
indexer::indexer(const af::seq& s0) {
122-
impl.mIndexer.seq = s0.s;
123-
impl.mIsSeq = true;
121+
index::index(const af::seq& s0) {
122+
impl.idx.seq = s0.s;
123+
impl.isSeq = true;
124124
impl.isBatch = s0.m_gfor;
125125
}
126126

127-
indexer::indexer(const af_seq& s0) {
128-
impl.mIndexer.seq = s0;
129-
impl.mIsSeq = true;
127+
index::index(const af_seq& s0) {
128+
impl.idx.seq = s0;
129+
impl.isSeq = true;
130130
impl.isBatch = false;
131131
}
132132

133-
indexer::indexer(const af::array& idx0) {
133+
index::index(const af::array& idx0) {
134134
array idx = idx0.isbool() ? where(idx0) : idx0;
135135
af_array arr = 0;
136136
AF_THROW(af_weak_copy(&arr, idx.get()));
137-
impl.mIndexer.arr = arr;
137+
impl.idx.arr = arr;
138138

139-
impl.mIsSeq = false;
139+
impl.isSeq = false;
140140
impl.isBatch = false;
141141
}
142142

@@ -145,12 +145,12 @@ static bool operator==(const af_seq& lhs, const af_seq& rhs) {
145145
return lhs.begin == rhs.begin && lhs.end == rhs.end && lhs.step == rhs.step;
146146
}
147147

148-
bool indexer::isspan() const
148+
bool index::isspan() const
149149
{
150-
return impl.mIsSeq == true && impl.mIndexer.seq == af_span;
150+
return impl.isSeq == true && impl.idx.seq == af_span;
151151
}
152152

153-
const af_index_t& indexer::get() const
153+
const af_index_t& index::get() const
154154
{
155155
return impl;
156156
}

src/backend/cpu/assign.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ void assign(Array<T>& out, const af_index_t idxrs[], const Array<T>& rhs)
4141
// create seq vector to retrieve output
4242
// dimensions, offsets & offsets
4343
for (dim_type x=0; x<4; ++x) {
44-
if (idxrs[x].mIsSeq) {
45-
seqs[x] = idxrs[x].mIndexer.seq;
44+
if (idxrs[x].isSeq) {
45+
seqs[x] = idxrs[x].idx.seq;
4646
}
47-
isSeq[x] = idxrs[x].mIsSeq;
47+
isSeq[x] = idxrs[x].isSeq;
4848
}
4949

5050
dim4 dDims = out.getDataDims();
@@ -58,14 +58,14 @@ void assign(Array<T>& out, const af_index_t idxrs[], const Array<T>& rhs)
5858
dim4 src_strides = rhs.strides();
5959

6060
std::vector< Array<uint> > idxArrs(4, createEmptyArray<uint>(dim4()));
61-
// look through indexers to read af_array indexers
61+
// look through indexs to read af_array indexs
6262
for (dim_type x=0; x<4; ++x) {
6363
if (!isSeq[x]) {
64-
idxArrs[x] = castArray<uint>(idxrs[x].mIndexer.arr);
64+
idxArrs[x] = castArray<uint>(idxrs[x].idx.arr);
6565
}
6666
}
6767

68-
// declare pointers to af_array indexer data
68+
// declare pointers to af_array index data
6969
const uint* ptr0 = idxArrs[0].get();
7070
const uint* ptr1 = idxArrs[1].get();
7171
const uint* ptr2 = idxArrs[2].get();

0 commit comments

Comments
 (0)