summaryrefslogtreecommitdiffhomepage
path: root/docs/cspan_api.md
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-07-24 08:48:41 +0200
committerGitHub <[email protected]>2023-07-24 08:48:41 +0200
commit374b3c27831cd4e09461867ed231669777b96951 (patch)
tree88011006f6d536cdb1ad1eca8073392ca80687cc /docs/cspan_api.md
parent177418232a2d8a8b0df1667d3e4bd15dc37db59f (diff)
parent650b053f443f9132dadb6d1ca924c0b36849739f (diff)
downloadSTC-modified-374b3c27831cd4e09461867ed231669777b96951.tar.gz
STC-modified-374b3c27831cd4e09461867ed231669777b96951.zip
Merge pull request #65 from stclib/dev43
Dev43
Diffstat (limited to 'docs/cspan_api.md')
-rw-r--r--docs/cspan_api.md25
1 files changed, 13 insertions, 12 deletions
diff --git a/docs/cspan_api.md b/docs/cspan_api.md
index 09821450..1312ae6d 100644
--- a/docs/cspan_api.md
+++ b/docs/cspan_api.md
@@ -21,19 +21,20 @@ using_cspan4(S, ValueType); // define span types S, S2, S3, S4 with
```
## Methods
-All functions are type-safe. Note that the span argument itself is generally not side-effect safe,
-i.e., it may be expanded multiple times. However, all index arguments are safe, e.g.
-`cspan_at(&ms3, i++, j++, k++)` is allowed. If the number of arguments does not match the span rank,
-a compile error is issued. Runtime bounds checks are enabled by default (define `STC_NDEBUG` or `NDEBUG` to disable).
+All functions are type-safe. NOTE: the span argument itself is generally **not** side-effect safe -
+it may be expanded multiple times. However, all index arguments are safe, e.g.
+`cspan_at(&ms3, i++, j++, k++)` is safe, but `cspan_at(&spans[n++], i, j)` is an error! If the number
+of arguments does not match the span rank, a compile error is issued. Runtime bounds checks are enabled
+by default (define `STC_NDEBUG` or `NDEBUG` to disable).
```c
-SpanType cspan_init(T SpanType, {v1, v2, ...}); // make a 1-d cspan from values
-SpanType cspan_from(STCContainer* cnt); // make a 1-d cspan from compatible STC container
-SpanType cspan_from_array(ValueType array[]); // make a 1-d cspan from C array
-
+SpanType cspan_init(TYPE SpanType, {v1, v2, ...}); // make a 1-d cspan from values
+SpanType cspan_from(STCContainer* cnt); // make a 1-d cspan from a cvec, cstack, cpque (heap)
+SpanType cspan_from_array(ValueType array[]); // make a 1-d cspan from a C array
+
intptr_t cspan_size(const SpanTypeN* self); // return number of elements
intptr_t cspan_rank(const SpanTypeN* self); // dimensions; compile time constant
intptr_t cspan_index(const SpanTypeN* self, intptr_t x, ..); // index of element
-
+
ValueType* cspan_at(const SpanTypeN* self, intptr_t x, ...); // #args must match input span rank
ValueType* cspan_front(const SpanTypeN* self);
ValueType* cspan_back(const SpanTypeN* self);
@@ -45,7 +46,7 @@ void SpanType_next(SpanTypeN_iter* it);
SpanTypeN cspan_md(ValueType* data, d1, d2, ...); // make a multi-dim cspan, row-major order.
SpanTypeN cspan_md_order(char order, ValueType* data, d1, d2, ...); // order='C': row-major, 'F': column-major (FORTRAN).
- // transpose a md span (inverse axes). no changes to the underlying array.
+ // transpose a md span (inverse axes). No changes to the underlying array.
void cspan_transpose(const SpanTypeN* self);
bool cspan_is_order_F(const SpanTypeN* self);
@@ -55,13 +56,13 @@ SpanType2 cspan_subspan2(const SpanType2* span, intptr_t offset, intptr_t
SpanType3 cspan_subspan3(const SpanType3* span, intptr_t offset, intptr_t count);
// create a sub md span of lower rank. Like e.g. cspan_slice(Span2, &ms4, {x}, {y}, {c_ALL}, {c_ALL});
-OutSpan1 cspan_submd2(const SpanType2* parent, intptr_t x); // return a 1d subspan from a 2d span.
+OutSpan cspan_submd2(const SpanType2* parent, intptr_t x); // return a 1d subspan from a 2d span.
OutSpanN cspan_submd3(const SpanType3* parent, intptr_t x, ...); // return a 1d or 2d subspan from a 3d span.
OutSpanN cspan_submd4(const SpanType4* parent, intptr_t x, ...); // number of args decides rank of output span.
// general slicing of an md span.
// {i}: reduce rank. {i,c_END}: slice to end. {c_ALL}: use full extent.
-OutSpanN cspan_slice(TYPE OutSpanN, const SpanTypeN* parent, {x0,x1}, {y0,y1}.., {N0,N1});
+OutSpanN cspan_slice(TYPE OutSpanN, const SpanTypeM* parent, {x0,x1}, {y0,y1}.., {N0,N1});
```
## TypesPd
| Type name | Type definition / usage | Used to represent... |