We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 887ae72 commit 714cdc0Copy full SHA for 714cdc0
4 files changed
src/api/cpp/array.cpp
@@ -374,8 +374,7 @@ namespace af
374
375
const array::array_proxy array::row(int index) const
376
{
377
- seq idx(index, index, 1);
378
- return this->operator()(idx, span, span, span);
+ return this->operator()(index, span, span, span);
379
}
380
381
array::array_proxy array::row(int index)
@@ -385,8 +384,7 @@ namespace af
385
384
386
const array::array_proxy array::col(int index) const
387
388
389
- return this->operator()(span, idx, span, span);
+ return this->operator()(span, index, span, span);
390
391
392
array::array_proxy array::col(int index)
@@ -396,8 +394,7 @@ namespace af
396
394
397
395
const array::array_proxy array::slice(int index) const
398
399
400
- return this->operator()(span, span, idx, span);
+ return this->operator()(span, span, index, span);
401
402
403
array::array_proxy array::slice(int index)
src/api/cpp/index.cpp
@@ -75,7 +75,7 @@ index::index(const af::array& idx0) {
75
impl.isBatch = false;
76
77
78
-index::index(const af::index& idx0) {
+index::index(const af::index& idx0) {
79
*this = idx0;
80
81
src/api/cpp/seq.cpp
@@ -46,7 +46,7 @@ seq::~seq()
46
seq::seq(double n): m_gfor(false)
47
48
if (n < 0) {
49
- init(n + 1, 0, 1); // seq(-4) = -3, -2, -1, 0
+ init(0, n, 1);
50
} else {
51
init(0, n - 1, 1);
52
src/backend/dim4.cpp
@@ -176,7 +176,7 @@ dim4 operator*(const dim4& first, const dim4& second)
176
177
178
bool
179
-isEnd(const af_seq &seq) { return (seq.end <= -1); }
+hasEnd(const af_seq &seq) { return (seq.begin <= -1 || seq.end <= -1); }
180
181
182
isSpan(const af_seq &seq) { return (seq.step == 0 && seq.begin == 1 && seq.end == 1); }
@@ -196,18 +196,11 @@ dim_t calcDim(const af_seq &seq, const dim_t &parentDim)
196
dim_t outDim = 1;
197
if (isSpan(seq)) {
198
outDim = parentDim;
199
- } else if (isEnd(seq)) {
200
- if(seq.begin == -1) { // only end is passed as seq
201
- outDim = 1;
202
- } else if (seq.begin < 0) {
203
- af_seq temp = {parentDim + seq.begin,
204
- parentDim + seq.end,
205
- seq.step};
206
- outDim = seqElements(temp);
207
- } else { // end is passed as a part of seq
208
- af_seq temp = {seq.begin, parentDim + seq.end, seq.step};
209
210
- }
+ } else if (hasEnd(seq)) {
+ af_seq temp = {seq.begin, seq.end, seq.step};
+ if (seq.begin < 0) temp.begin += parentDim;
+ if (seq.end < 0) temp.end += parentDim;
+ outDim = seqElements(temp);
211
212
DIM_ASSERT(1, seq.begin >= -DBL_MIN && seq.begin < parentDim);
213
DIM_ASSERT(1, seq.end < parentDim);
@@ -216,7 +209,8 @@ dim_t calcDim(const af_seq &seq, const dim_t &parentDim)
216
217
return outDim;
218
219
-}
+
+} // end namespace af
220
214
221
215
using af::dim4;
222
using std::vector;
0 commit comments