diff options
| author | Tylo <[email protected]> | 2020-06-23 17:45:43 +0200 |
|---|---|---|
| committer | Tylo <[email protected]> | 2020-06-23 17:45:43 +0200 |
| commit | 2ae6b220cc639ecc9cdfdabfe7be36aa2ed98b15 (patch) | |
| tree | 43d96e079d23553c92a00c750677a3ca89815f8f /examples | |
| parent | 7b50efc68e9339497345522fe7ffaf0833fb3869 (diff) | |
| download | STC-modified-2ae6b220cc639ecc9cdfdabfe7be36aa2ed98b15.tar.gz STC-modified-2ae6b220cc639ecc9cdfdabfe7be36aa2ed98b15.zip | |
Improved representation storage for CArray. Stores "owned" as highest bit in xdim.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/demos.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/examples/demos.c b/examples/demos.c index e05fa269..e8530b90 100644 --- a/examples/demos.c +++ b/examples/demos.c @@ -172,13 +172,16 @@ void mapdemo3() declare_CArray(f, float); -int arraydemo1() +void arraydemo1() { printf("\nARRAYDEMO1\n"); CArray3_f a3 = carray3_f_make(30, 20, 10, 0.f); carray3_f_data(a3, 5, 4)[3] = 10.2f; // a3[5][4][3] CArray2_f a2 = carray3_f_at(a3, 5); // sub-array reference (no data copy). + printf("a3: %zu: (%zu, %zu, %zu) = %zu\n", sizeof(a3), carray_xdim(a3), carray_ydim(a3), carray_zdim(a3), carray3_size(a3)); + printf("a2: %zu: (%zu, %zu) = %zu\n", sizeof(a2), carray_xdim(a2), carray_ydim(a2), carray2_size(a2)); + printf("%f\n", carray2_f_value(a2, 4, 3)); // readonly lookup a2[4][3] (=10.2f) printf("%f\n", carray2_f_data(a2, 4)[3]); // same, but this is writable. printf("%f\n", carray2_f_at(a2, 4).data[3]); // same, via sub-array access. @@ -186,7 +189,7 @@ int arraydemo1() printf("%f\n", carray3_f_value(a3, 5, 4, 3)); // same data location, via a3 array. printf("%f\n", carray3_f_data(a3, 5, 4)[3]); printf("%f\n", carray3_f_at2(a3, 5, 4).data[3]); - + carray2_f_destroy(&a2); // does nothing, since it is a sub-array. carray3_f_destroy(&a3); // also invalidates a2. } |
