From 27a6860137499e71eb23c1930ebe6e992baece12 Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Wed, 3 Nov 2021 13:11:56 +0100 Subject: Changed carrN_X_at() to return const value*. Added mutable carrN_X_elem(). --- include/stc/carr2.h | 5 ++++- include/stc/carr3.h | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/stc/carr2.h b/include/stc/carr2.h index 3f9d1540..a1dfc3ce 100644 --- a/include/stc/carr2.h +++ b/include/stc/carr2.h @@ -76,7 +76,10 @@ STC_INLINE size_t _cx_memb(_size)(_cx_self arr) STC_INLINE _cx_value *_cx_memb(_data)(_cx_self* self) { return *self->data; } -STC_INLINE _cx_value *_cx_memb(_at)(_cx_self* self, size_t x, size_t y) +STC_INLINE _cx_value *_cx_memb(_elem)(_cx_self* self, size_t x, size_t y) + { return *self->data + self->ydim*x + y; } + +STC_INLINE const _cx_value *_cx_memb(_at)(const _cx_self* self, size_t x, size_t y) { return *self->data + self->ydim*x + y; } STC_INLINE void _cx_memb(_copy)(_cx_self *self, _cx_self other) { diff --git a/include/stc/carr3.h b/include/stc/carr3.h index 1133dcc3..4d4fc84e 100644 --- a/include/stc/carr3.h +++ b/include/stc/carr3.h @@ -78,7 +78,10 @@ STC_INLINE size_t _cx_memb(_size)(_cx_self arr) STC_INLINE _cx_value* _cx_memb(_data)(_cx_self* self) { return **self->data; } -STC_INLINE _cx_value* _cx_memb(_at)(_cx_self* self, size_t x, size_t y, size_t z) +STC_INLINE _cx_value* _cx_memb(_elem)(_cx_self* self, size_t x, size_t y, size_t z) + { return **self->data + self->zdim*(self->ydim*x + y) + z; } + +STC_INLINE const _cx_value* _cx_memb(_at)(const _cx_self* self, size_t x, size_t y, size_t z) { return **self->data + self->zdim*(self->ydim*x + y) + z; } STC_INLINE void _cx_memb(_copy)(_cx_self *self, _cx_self other) { -- cgit v1.2.3