Skip to content

Conversation

@jmh530
Copy link
Contributor

@jmh530 jmh530 commented Jun 18, 2020

Facilitates easier access to slice contents, especially when not contiguous.

@codecov-commenter
Copy link

codecov-commenter commented Jun 18, 2020

Codecov Report

Merging #273 into master will increase coverage by 0.05%.
The diff coverage is 100.00%.

Impacted file tree graph

@@ Coverage Diff @@ ## master #273 +/- ## ========================================== + Coverage 90.46% 90.51% +0.05%  ========================================== Files 52 52 Lines 10991 11041 +50 ========================================== + Hits 9943 9994 +51  + Misses 1048 1047 -1 
Impacted Files Coverage Δ
source/mir/ndslice/slice.d 97.45% <100.00%> (+0.15%) ⬆️
source/mir/ndslice/iterator.d 93.80% <0.00%> (+0.23%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cf723a9...ced0614. Read the comment docs.

return n * _strides[0];
} else {
return indexStride(numIndex(n));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure this compiles, but the code is almost the same that was used in FlattenedIterator.

 ptrdiff_t valStride()(ptrdiff_t n) @safe scope const { ptrdiff_t _shift; foreach_reverse (i; Iota!(1, N)) { immutable v = n / ptrdiff_t(_lengths[i]); n %= ptrdiff_t(_lengths[i]); static if (i == S) _shift += n; else _shift += n * _strides[i]; n = v; } _shift += n * _strides[0]; return _shift; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw, any reason to make it public?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@9il Not really. indexStride was public and I tried to take the same approach. I can make changes private.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is ok to make it public, but I am not sure about naming, and we need docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as below. Happy to add more docs later today. Flexible on naming.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, this code is for Canonical and Universal slices. Contiguous should just return the n

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

}

///
auto ref at(size_t n) scope return @trusted
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also needs more docs and more verbose name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to add more docs later today. Any suggestion on name? Maybe access or accessFlat? I am flexible.

Along the same lines, should gmean/hmean be renamed geometricMean/harmonicMean? Might need deprecation given that there have been releases...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accessFlag looks good. Existing names in stat are good as well.

assert(mut == x);
}

size_t[N] numIndex(size_t n) @safe scope const
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused, can be removed though

@9il 9il merged commit c2934a1 into libmir:master Jun 19, 2020
@jmh530 jmh530 changed the title Add at/numStride/indexStride Add accessFlat/indexStrideValue Jun 19, 2020
@jmh530 jmh530 deleted the jmh530-at branch June 19, 2020 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants