Skip to content

Commit 120adc9

Browse files
committed
Auto-generated commit
1 parent 0a29a80 commit 120adc9

7 files changed

Lines changed: 360 additions & 16 deletions

File tree

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111
### Features
1212

13+
- [`3d21748`](https://github.com/stdlib-js/stdlib/commit/3d2174821f71a70dbb3052da07e0a3b3f6dfbaa0) - add function to return the index offset in units of elements
14+
- [`dd45a8f`](https://github.com/stdlib-js/stdlib/commit/dd45a8fcec70ba4716ec67606a448721a723f54b) - add function to return a dimension stride in units of elements
15+
- [`b00ba84`](https://github.com/stdlib-js/stdlib/commit/b00ba84689ed039d0896209f94716c187cd6cccb) - add function for returning the number of bytes per ndarray element
1316
- [`1e5789c`](https://github.com/stdlib-js/stdlib/commit/1e5789c70b7400b0ff1cd71d06798c1e5b26f16b) - add `blockSize` to namespace
1417
- [`a6117b1`](https://github.com/stdlib-js/stdlib/commit/a6117b1bd697083439d740567d41cbfa754f68ab) - add `quinaryBlockSize` to namespace
1518
- [`c6dca39`](https://github.com/stdlib-js/stdlib/commit/c6dca39c634f8c016dc6fa4d0330a47bba977eaf) - add `quaternaryBlockSize` to namespace
@@ -654,6 +657,11 @@
654657

655658
### BREAKING CHANGES
656659

660+
- [`cf38d87`](https://github.com/stdlib-js/stdlib/commit/cf38d87a6820408d2ec054cbf0e20561e8352deb): rename `stdlib_ndarray_bytelength` to `stdlib_ndarray_byte_length`
661+
662+
- To migrate, users using the C API should update their call signatures
663+
accordingly.
664+
657665
- [`45ca891`](https://github.com/stdlib-js/stdlib/commit/45ca891a86f94011ad8b407ba8cf53a7cecbb7b5): rename `with` to `ndarrayWith` in `ndarray` namespace
658666

659667
- Users should migrate to the new function name when using it directly via the namespace object.
@@ -727,6 +735,12 @@ A total of 43 issues were closed in this release:
727735

728736
<details>
729737

738+
- [`b6a0e1f`](https://github.com/stdlib-js/stdlib/commit/b6a0e1f3b0044a068a51acd7cd1352ab0f8e4a60) - **bench:** fix call signature _(by Athan Reines)_
739+
- [`3d21748`](https://github.com/stdlib-js/stdlib/commit/3d2174821f71a70dbb3052da07e0a3b3f6dfbaa0) - **feat:** add function to return the index offset in units of elements _(by Athan Reines)_
740+
- [`dd45a8f`](https://github.com/stdlib-js/stdlib/commit/dd45a8fcec70ba4716ec67606a448721a723f54b) - **feat:** add function to return a dimension stride in units of elements _(by Athan Reines)_
741+
- [`b00ba84`](https://github.com/stdlib-js/stdlib/commit/b00ba84689ed039d0896209f94716c187cd6cccb) - **feat:** add function for returning the number of bytes per ndarray element _(by Athan Reines)_
742+
- [`cf38d87`](https://github.com/stdlib-js/stdlib/commit/cf38d87a6820408d2ec054cbf0e20561e8352deb) - **refactor:** rename `stdlib_ndarray_bytelength` to `stdlib_ndarray_byte_length` _(by Athan Reines)_
743+
- [`40c30fb`](https://github.com/stdlib-js/stdlib/commit/40c30fb11f3c1b99e073b5a2aa217bce452c3402) - **docs:** fix type _(by Athan Reines)_
730744
- [`46c8d0e`](https://github.com/stdlib-js/stdlib/commit/46c8d0eb953a8bd39e4486a93d65aca6c45af934) - **docs:** fix examples _(by Athan Reines)_
731745
- [`9d7f220`](https://github.com/stdlib-js/stdlib/commit/9d7f220eca1b55eb1c59b1f31efd91f66a450af2) - **refactor:** use generalized utility _(by Athan Reines)_
732746
- [`7f54590`](https://github.com/stdlib-js/stdlib/commit/7f54590d0556e5c8b13d8bc2c527dbfc90e55201) - **refactor:** use generalized utility _(by Athan Reines)_

base/napi/addon-arguments/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ The function accepts the following arguments:
160160
- **argv**: `[in] napi_value*` ndarray function arguments.
161161
- **nargs**: `[in] int64_t` total number of expected arguments.
162162
- **nin**: `[in] int64_t` number of input ndarray arguments.
163-
- **arrays**: `[out] struct ndarrays**` destination array for storing pointers to both input and output ndarrays.
163+
- **arrays**: `[out] struct ndarray**` destination array for storing pointers to both input and output ndarrays.
164164
- **err**: `[out] napi_value*` pointer for storing a JavaScript error.
165165
166166
```c

ctor/README.md

Lines changed: 128 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ Notes:
882882
- The user is responsible for freeing the allocated memory.
883883
- To allocate a zero-dimensional ndarray, provide a `shape` argument equal to a null pointer, an `ndims` argument equal to `0`, and a `strides` argument consisting of a single element equal to `0`. The `order` argument can be either row-major or column-major and has no effect on data storage or access.
884884

885-
#### stdlib_ndarray_bytelength( \*arr )
885+
#### stdlib_ndarray_byte_length( \*arr )
886886

887887
Returns the size of an ndarray (in bytes).
888888

@@ -904,7 +904,7 @@ if ( x == NULL ) {
904904
// ...
905905

906906
// Retrieve the ndarray size:
907-
int64_t N = stdlib_ndarray_bytelength( x );
907+
int64_t N = stdlib_ndarray_byte_length( x );
908908

909909
// ...
910910

@@ -917,7 +917,45 @@ The function accepts the following arguments:
917917
- **arr**: `[in] struct ndarray*` input ndarray.
918918

919919
```c
920-
int64_t stdlib_ndarray_bytelength( const struct ndarray *arr );
920+
int64_t stdlib_ndarray_byte_length( const struct ndarray *arr );
921+
```
922+
923+
#### stdlib_ndarray_byte_length_per_element( \*arr )
924+
925+
Returns the number of bytes per ndarray element.
926+
927+
```c
928+
#include "stdlib/ndarray/ctor.h"
929+
#include <stdint.h>
930+
#include <stdlib.h>
931+
#include <stdio.h>
932+
933+
// ...
934+
935+
// Create an ndarray:
936+
struct ndarray *x = stdlib_ndarray_allocate( ... );
937+
if ( x == NULL ) {
938+
fprintf( stderr, "Error allocating memory.\n" );
939+
exit( 1 );
940+
}
941+
942+
// ...
943+
944+
// Retrieve the number of bytes per element:
945+
int64_t nb = stdlib_ndarray_byte_length_per_element( x );
946+
947+
// ...
948+
949+
// Free allocated memory:
950+
stdlib_ndarray_free( x );
951+
```
952+
953+
The function accepts the following arguments:
954+
955+
- **arr**: `[in] struct ndarray*` input ndarray.
956+
957+
```c
958+
int64_t stdlib_ndarray_byte_length_per_element( const struct ndarray *arr );
921959
```
922960

923961
#### stdlib_ndarray_data( \*arr )
@@ -1431,6 +1469,48 @@ The function accepts the following arguments:
14311469
int64_t stdlib_ndarray_offset( const struct ndarray *arr );
14321470
```
14331471

1472+
#### stdlib_ndarray_offset_elements( \*arr )
1473+
1474+
Returns an ndarray index offset (in elements).
1475+
1476+
```c
1477+
#include "stdlib/ndarray/ctor.h"
1478+
#include <stdint.h>
1479+
#include <stdlib.h>
1480+
#include <stdio.h>
1481+
1482+
// ...
1483+
1484+
// Create an ndarray:
1485+
struct ndarray *x = stdlib_ndarray_allocate( ... );
1486+
if ( x == NULL ) {
1487+
fprintf( stderr, "Error allocating memory.\n" );
1488+
exit( 1 );
1489+
}
1490+
1491+
// ...
1492+
1493+
// Retrieve the index offset:
1494+
int64_t offset = stdlib_ndarray_offset_elements( x );
1495+
1496+
// ...
1497+
1498+
// Free allocated memory:
1499+
stdlib_ndarray_free( x );
1500+
```
1501+
1502+
The function accepts the following arguments:
1503+
1504+
- **arr**: `[in] struct ndarray*` input ndarray.
1505+
1506+
```c
1507+
int64_t stdlib_ndarray_offset_elements( const struct ndarray *arr );
1508+
```
1509+
1510+
Notes:
1511+
1512+
- The function assumes that the ndarray is **aligned** (i.e., the index offset in bytes is a multiple of the number of bytes per ndarray element).
1513+
14341514
#### stdlib_ndarray_order( \*arr )
14351515

14361516
Returns the order of an ndarray.
@@ -1554,6 +1634,49 @@ Notes:
15541634

15551635
- The function does perform bounds checking for the dimension index.
15561636

1637+
#### stdlib_ndarray_stride_elements( \*arr, i )
1638+
1639+
Returns an ndarray stride (in elements).
1640+
1641+
```c
1642+
#include "stdlib/ndarray/ctor.h"
1643+
#include <stdint.h>
1644+
#include <stdlib.h>
1645+
#include <stdio.h>
1646+
1647+
// ...
1648+
1649+
// Create an ndarray:
1650+
struct ndarray *x = stdlib_ndarray_allocate( ... );
1651+
if ( x == NULL ) {
1652+
fprintf( stderr, "Error allocating memory.\n" );
1653+
exit( 1 );
1654+
}
1655+
1656+
// ...
1657+
1658+
// Retrieve a stride:
1659+
int64_t s = stdlib_ndarray_stride_elements( x, 0 );
1660+
1661+
// ...
1662+
1663+
// Free allocated memory:
1664+
stdlib_ndarray_free( x );
1665+
```
1666+
1667+
The function accepts the following arguments:
1668+
1669+
- **arr**: `[in] struct ndarray*` input ndarray.
1670+
- **i**: `[in] int64_t` dimension index.
1671+
1672+
```c
1673+
int64_t stdlib_ndarray_stride_elements( const struct ndarray *arr, const int64_t i );
1674+
```
1675+
1676+
Notes:
1677+
1678+
- The function does perform bounds checking for the dimension index.
1679+
15571680
#### stdlib_ndarray_strides( \*arr )
15581681

15591682
Returns a pointer to an array containing ndarray strides (in bytes).
@@ -3415,7 +3538,7 @@ int main( void ) {
34153538

34163539
printf( "dtype = %u\n", stdlib_ndarray_dtype( x1 ) );
34173540
printf( "length = %"PRId64"\n", stdlib_ndarray_length( x1 ) );
3418-
printf( "byteLength = %"PRId64"\n", stdlib_ndarray_bytelength( x1 ) );
3541+
printf( "byteLength = %"PRId64"\n", stdlib_ndarray_byte_length( x1 ) );
34193542
printf( "ltr = %u\n", stdlib_ndarray_dtype_char( stdlib_ndarray_dtype( x1 ) ) );
34203543
printf( "\n" );
34213544

@@ -3428,7 +3551,7 @@ int main( void ) {
34283551

34293552
printf( "dtype = %u\n", stdlib_ndarray_dtype( x2 ) );
34303553
printf( "length = %"PRId64"\n", stdlib_ndarray_length( x2 ) );
3431-
printf( "byteLength = %"PRId64"\n", stdlib_ndarray_bytelength( x2 ) );
3554+
printf( "byteLength = %"PRId64"\n", stdlib_ndarray_byte_length( x2 ) );
34323555
printf( "ltr = %u\n", stdlib_ndarray_dtype_char( stdlib_ndarray_dtype( x2 ) ) );
34333556
printf( "\n" );
34343557

0 commit comments

Comments
 (0)