summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-02-04 00:14:45 +0100
committerTyge Løvset <[email protected]>2023-02-04 00:14:45 +0100
commit51961138b16fbebacd76ce465fb979830d0f9701 (patch)
treeff0951a1970107df913853d69fb8d67a156e30c1
parent2f370b34484e63359f9fd2850b72d3d1d8dfc32a (diff)
downloadSTC-modified-51961138b16fbebacd76ce465fb979830d0f9701.tar.gz
STC-modified-51961138b16fbebacd76ce465fb979830d0f9701.zip
Minor docs update.
-rw-r--r--docs/cspan_api.md6
-rw-r--r--include/stc/cspan.h7
2 files changed, 4 insertions, 9 deletions
diff --git a/docs/cspan_api.md b/docs/cspan_api.md
index 66a7b01b..616b090e 100644
--- a/docs/cspan_api.md
+++ b/docs/cspan_api.md
@@ -16,7 +16,6 @@ using_cspan(SpanTypeN, ValueType, Rank); // define multi-dimensional span with R
using_cspan2(S, ValueType); // define span types S, S2 with ranks 1, 2.
using_cspan3(S, ValueType); // define span types S, S2, S3 with ranks 1, 2, 3.
using_cspan4(S, ValueType); // define span types S, S2, S3, S4 with ranks 1, 2, 3, 4.
-using_cspan5(S, ValueType); // define span types S, S2, .., S5 with ranks 1, 2, 3, 4, 5.
```
## Methods
Note that `cspan_md()`, `cmake_from*()`, `cspan_atN()`, `and cspan_subspanN()` require a (safe) cast to its span-type
@@ -35,15 +34,14 @@ ValueType* cspan_at(const SpanTypeN* self, intptr_t x, ...); // at(): num
ValueType* cspan_front(const SpanTypeN* self);
ValueType* cspan_back(const SpanTypeN* self);
- // general slicing to create a subspan.
- // {ind} reduces rank. {ind,c_END} slice to end. {c_ALL} take the full extent.
+ // general index slicing to create a subspan.
+ // {x} reduces rank. {x,c_END} slice to end. {c_ALL} take the full extent.
SpanTypeN cspan_slice(T SpanTypeN, const SpanTypeM* parent, {x0,x1}, {y0,y1}, ...);
// create a subspan of lower rank. Like e.g. cspan_slice(Span2, &ms3, {x}, {c_ALL}, {c_ALL});
SpanType cspan_submd2(const SpanType2* self, intptr_t x); // return a 1d subspan from a 2d span.
SpanTypeN cspan_submd3(const SpanType3* self, intptr_t x, ...); // return a 1d or 2d subspan from a 3d span.
SpanTypeN cspan_submd4(const SpanType4* self, intptr_t x, ...); // number of args determines rank of output span.
-SpanTypeN cspan_submd5(const SpanType5* self, intptr_t x, ...);
// create a subspan of same rank. Like e.g. cspan_slice(Span3, &ms3, {off, off+count}, {c_ALL}, {c_ALL});
SpanType cspan_subspan(const SpanType* self, intptr_t offset, intptr_t count);
diff --git a/include/stc/cspan.h b/include/stc/cspan.h
index 3ddc9742..bee67863 100644
--- a/include/stc/cspan.h
+++ b/include/stc/cspan.h
@@ -134,10 +134,10 @@ typedef struct { int32_t d[6]; } cspan_idx6;
#define cspan_idx_2 cspan_idx_4
#define cspan_idx_3 cspan_idx_4
#define cspan_idx_4(self, ...) \
- c_PASTE(_cspan_idx, c_NUMARGS(__VA_ARGS__))((self)->shape, (self)->stride, __VA_ARGS__)
+ c_PASTE(_cspan_idx, c_NUMARGS(__VA_ARGS__))((self)->shape, (self)->stride, __VA_ARGS__) // small/fast
#define cspan_idx_5(self, ...) \
(_cspan_idxN(c_NUMARGS(__VA_ARGS__), (self)->shape, (self)->stride.d, (int32_t[]){__VA_ARGS__}) + \
- c_static_assert(cspan_rank(self) == c_NUMARGS(__VA_ARGS__)))
+ c_static_assert(cspan_rank(self) == c_NUMARGS(__VA_ARGS__))) // general
#define cspan_idx_6 cspan_idx_5
#define cspan_at(self, ...) ((self)->data + cspan_index(self, __VA_ARGS__))
@@ -151,9 +151,6 @@ typedef struct { int32_t d[6]; } cspan_idx6;
{.data=cspan_at(self, offset, 0), .shape={count, (self)->shape[1]}, .stride={(self)->stride}}
#define cspan_subspan3(self, offset, count) \
{.data=cspan_at(self, offset, 0, 0), .shape={count, (self)->shape[1], (self)->shape[2]}, .stride={(self)->stride}}
-#define cspan_subspan4(self, offset, count) \
- {.data=cspan_at(self, offset, 0, 0, 0), .shape={count, (self)->shape[1], (self)->shape[2], (self)->shape[3]}, \
- .stride={(self)->stride}}
// cspan_submdN: return reduced rank
#define cspan_submd4(...) c_MACRO_OVERLOAD(cspan_submd4, __VA_ARGS__)