Gathering detailed insights and metrics for @stdlib/ndarray-ctor
Gathering detailed insights and metrics for @stdlib/ndarray-ctor
Gathering detailed insights and metrics for @stdlib/ndarray-ctor
Gathering detailed insights and metrics for @stdlib/ndarray-ctor
npm install @stdlib/ndarray-ctor
Typescript
Module System
Min. Node Version
Node Version
NPM Version
C (82.06%)
JavaScript (17.94%)
Total Downloads
301,429
Last Day
139
Last Week
1,629
Last Month
6,424
Last Year
85,266
Apache-2.0 License
3 Stars
77 Commits
3 Watchers
5 Branches
14 Contributors
Updated on Apr 14, 2025
Minified
Minified + Gzipped
Latest Version
0.2.2
Package Id
@stdlib/ndarray-ctor@0.2.2
Unpacked Size
307.69 kB
Size
37.38 kB
File Count
36
NPM Version
8.19.4
Node Version
16.20.2
Published on
Jul 29, 2024
Cumulative downloads
Total Downloads
Last Day
239%
139
Compared to previous day
Last Week
1.4%
1,629
Compared to previous week
Last Month
14.8%
6,424
Compared to previous month
Last Year
-19.6%
85,266
Compared to previous year
32
We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.
The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.
When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.
To join us in bringing numerical computing to the web, get started by checking us out on GitHub, and please consider financially supporting stdlib. We greatly appreciate your continued support!
[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url]
Multidimensional array constructor.
1npm install @stdlib/ndarray-ctor
1var ndarray = require( '@stdlib/ndarray-ctor' );
Returns an ndarray
instance.
1// Specify the array configuration: 2var buffer = [ 1.0, 2.0, 3.0, 4.0 ]; 3var shape = [ 2, 2 ]; 4var order = 'row-major'; 5var strides = [ 2, 1 ]; 6var offset = 0; 7 8// Create a new ndarray: 9var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); 10// returns <ndarray>
The constructor expects the following arguments:
row-major
(C-style) or column-major
(Fortran-style).The constructor accepts the following options
:
'throw'
.[ options.mode ]
.boolean
indicating whether an array should be read-only. Default: false
.The constructor supports the following modes
:
ndarray
instance should throw an error when an index exceeds array dimensions.ndarray
instance should normalize negative indices and throw an error when an index exceeds array dimensions.ndarray
instance should wrap around an index exceeding array dimensions using modulo arithmetic.ndarray
instance should set an index exceeding array dimensions to either 0
(minimum index) or the maximum index.By default, an ndarray
instance throws when provided an index which exceeds array dimensions. To support alternative indexing behavior, set the mode
option, which will affect all public methods for getting and setting array elements.
1var opts = { 2 'mode': 'clamp' 3}; 4 5// Specify the array configuration: 6var buffer = [ 1.0, 2.0, 3.0, 4.0 ]; 7var shape = [ 2, 2 ]; 8var order = 'row-major'; 9var strides = [ 2, 1 ]; 10var offset = 0; 11 12// Create a new ndarray: 13var arr = ndarray( 'generic', buffer, shape, strides, offset, order, opts ); 14// returns <ndarray> 15 16// Attempt to access an out-of-bounds linear index (clamped): 17var v = arr.iget( 10 ); 18// returns 4.0
By default, the mode
option is applied to subscripts which exceed array dimensions. To specify behavior for each dimension, set the submode
option.
1var opts = { 2 'submode': [ 'wrap', 'clamp' ] 3}; 4 5// Specify the array configuration: 6var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; 7var shape = [ 2, 2, 2 ]; 8var order = 'row-major'; 9var strides = [ 4, 2, 1 ]; 10var offset = 0; 11 12// Create a new ndarray: 13var arr = ndarray( 'generic', buffer, shape, strides, offset, order, opts ); 14// returns <ndarray> 15 16// Attempt to access out-of-bounds subscripts: 17var v = arr.get( -2, 10, -1 ); // linear index: 3 18// returns 4.0
String value of the ndarray constructor name.
1var str = ndarray.name; 2// returns 'ndarray'
Size (in bytes) of the array (if known).
1var Float64Array = require( '@stdlib/array-float64' ); 2 3// Specify the array configuration: 4var buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); 5var shape = [ 2, 2 ]; 6var order = 'row-major'; 7var strides = [ 2, 1 ]; 8var offset = 0; 9 10// Create a new ndarray: 11var arr = ndarray( 'float64', buffer, shape, strides, offset, order ); 12 13// Get the byte length: 14var nbytes = arr.byteLength; 15// returns 32
If unable to determine the size of the array, the property value is null
.
1// Specify the array configuration: 2var buffer = [ 1.0, 2.0, 3.0, 4.0 ]; 3var shape = [ 2, 2 ]; 4var order = 'row-major'; 5var strides = [ 2, 1 ]; 6var offset = 0; 7 8// Create a new ndarray: 9var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); 10 11// Get the byte length: 12var nbytes = arr.byteLength; 13// returns null
Size (in bytes) of each array element (if known).
1var Float32Array = require( '@stdlib/array-float32' ); 2 3// Specify the array configuration: 4var buffer = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); 5var shape = [ 2, 2 ]; 6var order = 'row-major'; 7var strides = [ 2, 1 ]; 8var offset = 0; 9 10// Create a new ndarray: 11var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); 12 13// Get the number of bytes per element: 14var nbytes = arr.BYTES_PER_ELEMENT; 15// returns 4
If size of each array element is unknown, the property value is null
.
1// Specify the array configuration: 2var buffer = [ 1.0, 2.0, 3.0, 4.0 ]; 3var shape = [ 2, 2 ]; 4var order = 'row-major'; 5var strides = [ 2, 1 ]; 6var offset = 0; 7 8// Create a new ndarray: 9var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); 10 11// Get the number of bytes per element: 12var nbytes = arr.BYTES_PER_ELEMENT; 13// returns null
A reference to the underlying data buffer.
1var Int8Array = require( '@stdlib/array-int8' ); 2 3// Specify the array configuration: 4var buffer = new Int8Array( [ 1, 2, 3, 4 ] ); 5var shape = [ 2, 2 ]; 6var order = 'row-major'; 7var strides = [ 2, 1 ]; 8var offset = 0; 9 10// Create a new ndarray: 11var arr = ndarray( 'int8', buffer, shape, strides, offset, order ); 12 13// Get the buffer reference: 14var d = arr.data; 15// returns <Int8Array>[ 1, 2, 3, 4 ] 16 17var bool = ( d === buffer ); 18// returns true
Underlying [data type][@stdlib/ndarray/dtypes].
1var Uint8Array = require( '@stdlib/array-uint8' ); 2 3// Specify the array configuration: 4var buffer = new Uint8Array( [ 1, 2, 3, 4 ] ); 5var shape = [ 2, 2 ]; 6var order = 'row-major'; 7var strides = [ -2, 1 ]; 8var offset = 2; 9 10// Create a new ndarray: 11var arr = ndarray( 'uint8', buffer, shape, strides, offset, order ); 12 13// Get the underlying data type: 14var dtype = arr.dtype; 15// returns 'uint8'
Meta information, such as information regarding the memory layout of the array. The returned object
has the following properties:
boolean
indicating if an array is row-major contiguous.boolean
indicating if an array is column-major contiguous.boolean
indicating whether an array is read-only.An array is contiguous if (1) an array is compatible with being stored in a single memory segment and (2) each array element is adjacent to the next array element. Note that an array can be both row-major contiguous and column-major contiguous at the same time (e.g., if an array is a 1-dimensional ndarray with strides = [1]
).
1var Int32Array = require( '@stdlib/array-int32' ); 2 3// Specify the array configuration: 4var buffer = new Int32Array( [ 1, 2, 3, 4 ] ); 5var shape = [ 2, 2 ]; 6var order = 'column-major'; 7var strides = [ 1, 2 ]; 8var offset = 0; 9 10// Create a new ndarray: 11var arr = ndarray( 'int32', buffer, shape, strides, offset, order ); 12 13// Get the array flags: 14var flg = arr.flags; 15// returns {...}
Number of array elements.
1var Uint16Array = require( '@stdlib/array-uint16' ); 2 3// Specify the array configuration: 4var buffer = new Uint16Array( [ 1, 2, 3, 4 ] ); 5var shape = [ 2, 2 ]; 6var order = 'column-major'; 7var strides = [ -1, -2 ]; 8var offset = 3; 9 10// Create a new ndarray: 11var arr = ndarray( 'uint16', buffer, shape, strides, offset, order ); 12 13// Get the array length: 14var len = arr.length; 15// returns 4
Number of dimensions.
1var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); 2 3// Specify the array configuration: 4var buffer = new Uint8ClampedArray( [ 1, 2, 3, 4 ] ); 5var shape = [ 2, 2 ]; 6var order = 'row-major'; 7var strides = [ -2, -1 ]; 8var offset = 3; 9 10// Create a new ndarray: 11var arr = ndarray( 'uint8c', buffer, shape, strides, offset, order ); 12 13// Get the number of dimensions: 14var ndims = arr.ndims; 15// returns 2
Index offset which specifies the buffer
index at which to start iterating over array elements.
1var Int16Array = require( '@stdlib/array-int16' ); 2 3// Specify the array configuration: 4var buffer = new Int16Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] ); 5var shape = [ 2, 2 ]; 6var order = 'row-major'; 7var strides = [ -2, -1 ]; 8var offset = 10; 9 10// Create a new ndarray: 11var arr = ndarray( 'int16', buffer, shape, strides, offset, order ); 12 13// Get the index offset: 14var o = arr.offset; 15// returns 10
Array order. The array order is either row-major (C-style) or column-major (Fortran-style).
1var Uint32Array = require( '@stdlib/array-uint32' ); 2 3// Specify the array configuration: 4var buffer = new Uint32Array( [ 1, 2, 3, 4 ] ); 5var shape = [ 2, 2 ]; 6var order = 'row-major'; 7var strides = [ 2, 1 ]; 8var offset = 0; 9 10// Create a new ndarray: 11var arr = ndarray( 'uint32', buffer, shape, strides, offset, order ); 12 13// Get the array order: 14var ord = arr.order; 15// returns 'row-major'
Returns a copy of the array shape.
1// Specify the array configuration: 2var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; 3var shape = [ 2, 2 ]; 4var order = 'row-major'; 5var strides = [ 2, 1 ]; 6var offset = 2; 7 8// Create a new ndarray: 9var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); 10 11// Get the array shape: 12var dims = arr.shape; 13// returns [ 2, 2 ]
Returns a copy of the array strides which specify how to access data along corresponding array dimensions.
1// Specify the array configuration: 2var buffer = [ 1.0, 2.0, 3.0, 4.0 ]; 3var shape = [ 2, 2 ]; 4var order = 'column-major'; 5var strides = [ -1, 2 ]; 6var offset = 1; 7 8// Create a new ndarray: 9var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); 10 11// Get the array strides: 12var s = arr.strides; 13// returns [ -1, 2 ]
Returns an array element specified according to provided subscripts. The number of provided subscripts must equal the number of dimensions.
1// Specify the array configuration: 2var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; 3var shape = [ 2, 2 ]; 4var order = 'row-major'; 5var strides = [ 2, 1 ]; 6var offset = 2; 7 8// Create a new ndarray: 9var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); 10 11// Get the element located at (1,1): 12var v = arr.get( 1, 1 ); 13// returns 6.0
Returns an array element located at a specified linear index.
1// Specify the array configuration: 2var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; 3var shape = [ 2, 2 ]; 4var order = 'row-major'; 5var strides = [ 2, 1 ]; 6var offset = 2; 7 8// Create a new ndarray: 9var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); 10 11// Get the element located at index 3: 12var v = arr.iget( 3 ); 13// returns 6.0
For zero-dimensional arrays, the input argument is ignored and, for clarity, should not be provided.
Sets an array element specified according to provided subscripts. The number of provided subscripts must equal the number of dimensions.
1// Specify the array configuration: 2var buffer = [ 1.0, 2.0, 3.0, 4.0 ]; 3var shape = [ 2, 2 ]; 4var order = 'row-major'; 5var strides = [ 2, 1 ]; 6var offset = 0; 7 8// Create a new ndarray: 9var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); 10 11// Set the element located at (1,1): 12arr.set( 1, 1, 40.0 ); 13var v = arr.get( 1, 1 ); 14// returns 40.0 15 16// Get the underlying buffer: 17var d = arr.data; 18// returns [ 1.0, 2.0, 3.0, 40.0 ]
The method returns the ndarray
instance. If an array is read-only, the method raises an exception.
Sets an array element located at a specified linear index.
1// Specify the array configuration: 2var buffer = [ 1.0, 2.0, 3.0, 4.0 ]; 3var shape = [ 2, 2 ]; 4var order = 'row-major'; 5var strides = [ 2, 1 ]; 6var offset = 0; 7 8// Create a new ndarray: 9var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); 10 11// Set the element located at index 3: 12arr.iset( 3, 40.0 ); 13var v = arr.iget( 3 ); 14// returns 40.0 15 16// Get the underlying buffer: 17var d = arr.data; 18// returns [ 1.0, 2.0, 3.0, 40.0 ]
For zero-dimensional arrays, the first, and only, argument should be the value v
to set.
The method returns the ndarray
instance. If an array is read-only, the method raises an exception.
Serializes an ndarray
as a string
.
1// Specify the array configuration: 2var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; 3var shape = [ 3, 2 ]; 4var order = 'row-major'; 5var strides = [ 2, 1 ]; 6var offset = 2; 7 8// Create a new ndarray: 9var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); 10 11// Serialize to a string: 12var str = arr.toString(); 13// returns "ndarray( 'generic', [ 3, 4, 5, 6, 7, 8 ], [ 3, 2 ], [ 2, 1 ], 0, 'row-major' )"
The method does not serialize data outside of the buffer region defined by the array configuration.
Serializes an ndarray
as a [JSON][json] object
. JSON.stringify()
implicitly calls this method when stringifying an ndarray
instance.
1// Specify the array configuration: 2var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ]; 3var shape = [ 3, 2 ]; 4var order = 'row-major'; 5var strides = [ 2, 1 ]; 6var offset = 2; 7 8// Create a new ndarray: 9var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); 10 11// Serialize to JSON: 12var o = arr.toJSON(); 13// returns { 'type': 'ndarray', 'dtype': 'generic', 'flags': {...}, 'offset': 0, 'order': 'row-major', 'shape': [ 3, 2 ], 'strides': [ 2, 1 ], 'data': [ 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] }
The method does not serialize data outside of the buffer region defined by the array configuration.
To create a zero-dimensional array, provide an empty shape
and a single strides
element equal to 0
. The order
can be either row-major
or column-major
and has no effect on data storage or access.
1var buffer = [ 1 ]; 2var shape = []; 3var order = 'row-major'; 4var strides = [ 0 ]; 5var offset = 0; 6 7// Create a new zero-dimensional array: 8var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); 9// returns <ndarray>
1var Float32Array = require( '@stdlib/array-float32' ); 2var ndarray = require( '@stdlib/ndarray-ctor' ); 3 4// Create a data buffer: 5var buffer = new Float32Array( (3*3*3*3) + 100 ); 6 7// Specify the array shape: 8var shape = [ 3, 3, 3, 3 ]; 9 10// Specify the array strides: 11var strides = [ 27, 9, 3, 1 ]; 12 13// Specify the index offset: 14var offset = 4; 15 16// Specify the order: 17var order = 'row-major'; // C-style 18 19// Create a new ndarray: 20var arr = ndarray( 'float32', buffer, shape, strides, offset, order ); 21 22// Retrieve an array value: 23var v = arr.get( 1, 2, 1, 2 ); 24// returns 0.0 25 26// Set an array value: 27arr.set( 1, 2, 1, 2, 10.0 ); 28 29// Retrieve the array value: 30v = arr.get( 1, 2, 1, 2 ); 31// returns 10.0 32 33// Serialize the array as a string: 34var str = arr.toString(); 35// returns "ndarray( 'float32', new Float32Array( [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] ), [ 3, 3, 3, 3 ], [ 27, 9, 3, 1 ], 0, 'row-major' )" 36 37// Serialize the array as JSON: 38str = JSON.stringify( arr.toJSON() ); 39// e.g., returns '{"type":"ndarray","dtype":"float32","flags":{"READONLY":false},"order":"row-major","shape":[3,3,3,3],"strides":[27,9,3,1],"data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}'
1#include "stdlib/ndarray/ctor.h"
Structure holding ndarray data.
1#include "stdlib/ndarray/dtypes.h" 2#include "stdlib/ndarray/index_modes.h" 3#include "stdlib/ndarray/orders.h" 4#include "stdlib/ndarray/base/bytes_per_element.h" 5#include <stdint.h> 6 7struct ndarray { 8 // Underlying data type: 9 int16_t dtype; 10 11 // Pointer to the underlying byte array: 12 uint8_t *data; 13 14 // Number of array dimensions: 15 int64_t ndims; 16 17 // Array shape (dimensions): 18 int64_t *shape; 19 20 // Array strides (in bytes) specifying how to iterate over a strided array: 21 int64_t *strides; 22 23 // Byte offset which specifies the location at which to start iterating over array elements: 24 int64_t offset; 25 26 // Array order (either row-major (C-style) or column-major (Fortran-style)): 27 int8_t order; 28 29 // Mode specifying how to handle indices which exceed array dimensions: 30 int8_t imode; 31 32 // Number of subscript modes: 33 int64_t nsubmodes; 34 35 // Mode(s) specifying how to handle subscripts which exceed array dimensions on a per dimension basis: 36 int8_t *submodes; 37 38 // Number of array elements: 39 int64_t length; 40 41 // Size in bytes: 42 int64_t byteLength; 43 44 // Number of bytes per element (i.e., item size): 45 int64_t BYTES_PER_ELEMENT; 46 47 // Bit mask providing information regarding the memory layout of the array (e.g., see macros): 48 int64_t flags; 49};
Macro defining a flag indicating whether an ndarray is row-major (C-style) contiguous.
1#define STDLIB_NDARRAY_ROW_MAJOR_CONTIGUOUS_FLAG 0x0001
Notes:
strides
array is in reverse order to that of column-major order.Macro defining a flag indicating whether an ndarray is column-major (Fortran-style) contiguous.
1#define STDLIB_NDARRAY_COLUMN_MAJOR_CONTIGUOUS_FLAG 0x0002
Notes:
strides
array is in reverse order to that of row-major order.Returns a pointer to a dynamically allocated ndarray.
1#include "stdlib/ndarray/ctor.h" 2#include "stdlib/ndarray/dtypes.h" 3#include "stdlib/ndarray/index_modes.h" 4#include "stdlib/ndarray/orders.h" 5#include "stdlib/ndarray/base/bytes_per_element.h" 6#include <stdlib.h> 7#include <stdio.h> 8#include <stdint.h> 9 10// Specify the underlying data type: 11enum STDLIB_NDARRAY_DTYPE dtype = STDLIB_NDARRAY_FLOAT64; 12 13// Create an underlying byte array: 14uint8_t buffer[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 15 16// Specify the number of array dimensions: 17int64_t ndims = 1; 18 19// Specify the array shape: 20int64_t shape[] = { 3 }; // vector consisting of 3 doubles 21 22// Specify the array strides: 23int64_t strides[] = { STDLIB_NDARRAY_FLOAT64_BYTES_PER_ELEMENT }; 24 25// Specify the byte offset: 26int64_t offset = 0; 27 28// Specify the array order (note: this does not matter for a 1-dimensional array): 29enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; 30 31// Specify the index mode: 32enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; 33 34// Specify the subscript index modes: 35int8_t submodes[] = { STDLIB_NDARRAY_INDEX_ERROR }; 36int64_t nsubmodes = 1; 37 38// Create an ndarray: 39struct ndarray *x = stdlib_ndarray_allocate( dtype, buffer, ndims, shape, strides, offset, order, imode, nsubmodes, submodes ); 40if ( x == NULL ) { 41 fprintf( stderr, "Error allocating memory.\n" ); 42 exit( 1 ); 43} 44 45// Free allocated memory: 46stdlib_ndarray_free( x );
The function accepts the following arguments:
[in] int16_t
[data type][@stdlib/ndarray/dtypes].[in] uint8_t*
pointer to the underlying byte array.[in] int64_t
number of dimensions.[in] int64_t*
array shape (i.e., dimensions).[in] int64_t*
array strides (in bytes).[in] int64_t
byte offset specifying the location of the first element.[in] int8_t
specifies whether an array is [row-major][@stdlib/ndarray/orders] (C-style) or [column-major][@stdlib/ndarray/orders] (Fortran-style).[in] int8_t
specifies the [index mode][@stdlib/ndarray/index-modes] (i.e., how to handle indices which exceed array dimensions).[in] int64_t
number of subscript modes.[in] int8_t*
specifies how to handle subscripts which [exceed][@stdlib/ndarray/index-modes] array dimensions on a per dimension basis (if provided fewer submodes than dimensions, submodes are recycled using modulo arithmetic).1struct ndarray * stdlib_ndarray_allocate( int16_t dtype, uint8_t *data, int64_t ndims, int64_t *shape, int64_t *strides, int64_t offset, int8_t order, int8_t imode, int64_t nsubmodes, int8_t *submodes );
Notes:
Returns the size of an ndarray (in bytes).
1#include "stdlib/ndarray/ctor.h" 2#include <stdint.h> 3#include <stdlib.h> 4#include <stdio.h> 5 6// ... 7 8// Create an ndarray: 9struct ndarray *x = stdlib_ndarray_allocate( ... ); 10if ( x == NULL ) { 11 fprintf( stderr, "Error allocating memory.\n" ); 12 exit( 1 ); 13} 14 15// ... 16 17// Retrieve the ndarray size: 18int64_t N = stdlib_ndarray_bytelength( x ); 19 20// ... 21 22// Free allocated memory: 23stdlib_ndarray_free( x );
The function accepts the following arguments:
[in] struct ndarray*
input ndarray.1int64_t stdlib_ndarray_bytelength( const struct ndarray *arr );
Returns a pointer to an ndarray's underlying byte array.
1#include "stdlib/ndarray/ctor.h" 2#include <stdint.h> 3#include <stdlib.h> 4#include <stdio.h> 5 6// ... 7 8// Create an ndarray: 9struct ndarray *x = stdlib_ndarray_allocate( ... ); 10if ( x == NULL ) { 11 fprintf( stderr, "Error allocating memory.\n" ); 12 exit( 1 ); 13} 14 15// ... 16 17// Retrieve the underlying byte array: 18uint8_t *data = stdlib_ndarray_data( x ); 19 20// ... 21 22// Free allocated memory: 23stdlib_ndarray_free( x );
The function accepts the following arguments:
[in] struct ndarray*
input ndarray.1uint8_t * stdlib_ndarray_data( const struct ndarray *arr );
Returns an ndarray dimension.
1#include "stdlib/ndarray/ctor.h" 2#include <stdint.h> 3#include <stdlib.h> 4#include <stdio.h> 5 6// ... 7 8// Create an ndarray: 9struct ndarray *x = stdlib_ndarray_allocate( ... ); 10if ( x == NULL ) { 11 fprintf( stderr, "Error allocating memory.\n" ); 12 exit( 1 ); 13} 14 15// ... 16 17// Retrieve a dimension: 18int64_t dim = stdlib_ndarray_dimension( x, 0 ); 19 20// ... 21 22// Free allocated memory: 23stdlib_ndarray_free( x );
The function accepts the following arguments:
[in] struct ndarray*
input ndarray.[in] int64_t
dimension index.1int64_t stdlib_ndarray_dimension( const struct ndarray *arr, const int64_t i );
Notes:
Disables specified ndarray flags.
1#include "stdlib/ndarray/ctor.h" 2#include <stdint.h> 3#include <stdlib.h> 4#include <stdio.h> 5 6// ... 7 8// Create an ndarray: 9struct ndarray *x = stdlib_ndarray_allocate( ... ); 10if ( x == NULL ) { 11 fprintf( stderr, "Error allocating memory.\n" ); 12 exit( 1 ); 13} 14 15// ... 16 17// Disables specified ndarray flags: 18int8_t status = stdlib_ndarray_disable_flags( x, STDLIB_NDARRAY_ROW_MAJOR_CONTIGUOUS_FLAG ); 19 20// ... 21 22// Free allocated memory: 23stdlib_ndarray_free( x );
The function accepts the following arguments:
[in] struct ndarray*
input ndarray.[in] int64_t
bit mask to disable flags.The function returns a status code of 0
if able to successfully disable flags.
1int8_t stdlib_ndarray_disable_flags( const struct ndarray *arr, const int64_t flags );
Notes:
Returns the data type of an ndarray.
1#include "stdlib/ndarray/ctor.h" 2#include "stdlib/ndarray/dtypes.h" 3#include <stdlib.h> 4#include <stdio.h> 5 6// ... 7 8// Create an ndarray: 9struct ndarray *x = stdlib_ndarray_allocate( ... ); 10if ( x == NULL ) { 11 fprintf( stderr, "Error allocating memory.\n" ); 12 exit( 1 ); 13} 14 15// ... 16 17// Retrieve the dtype: 18enum STDLIB_NDARRAY_DTYPE dtype = stdlib_ndarray_dtype( x ); 19 20// ... 21 22// Free allocated memory: 23stdlib_ndarray_free( x );
The function accepts the following arguments:
[in] struct ndarray*
input ndarray.1int16_t stdlib_ndarray_dtype( const struct ndarray *arr );
Enables specified ndarray flags.
1#include "stdlib/ndarray/ctor.h" 2#include <stdint.h> 3#include <stdlib.h> 4#include <stdio.h> 5 6// ... 7 8// Create an ndarray: 9struct ndarray *x = stdlib_ndarray_allocate( ... ); 10if ( x == NULL ) { 11 fprintf( stderr, "Error allocating memory.\n" ); 12 exit( 1 ); 13} 14 15// ... 16 17// Enables specified ndarray flags: 18int8_t status = stdlib_ndarray_enable_flags( x, STDLIB_NDARRAY_ROW_MAJOR_CONTIGUOUS_FLAG ); 19 20// ... 21 22// Free allocated memory: 23stdlib_ndarray_free( x );
The function accepts the following arguments:
[in] struct ndarray*
input ndarray.[in] int64_t
bit mask to enable flags.The function returns a status code of 0
if able to successfully enable flags.
1int8_t stdlib_ndarray_enable_flags( const struct ndarray *arr, const int64_t flags );
Notes:
Returns ndarray flags as a single integer value.
1#include "stdlib/ndarray/ctor.h" 2#include <stdint.h> 3#include <stdlib.h> 4#include <stdio.h> 5 6// ... 7 8// Create an ndarray: 9struct ndarray *x = stdlib_ndarray_allocate( ... ); 10if ( x == NULL ) { 11 fprintf( stderr, "Error allocating memory.\n" ); 12 exit( 1 ); 13} 14 15// ... 16 17// Retrieve the ndarray flags: 18int64_t flags = stdlib_ndarray_flags( x ); 19 20// ... 21 22// Free allocated memory: 23stdlib_ndarray_free( x );
The function accepts the following arguments:
[in] struct ndarray*
input ndarray.1int64_t stdlib_ndarray_flags( const struct ndarray *arr );
Frees an ndarray's allocated memory.
1#include "stdlib/ndarray/ctor.h" 2#include <stdlib.h> 3#include <stdio.h> 4 5// ... 6 7// Create an ndarray: 8struct ndarray *x = stdlib_ndarray_allocate( ... ); 9if ( x == NULL ) { 10 fprintf( stderr, "Error allocating memory.\n" ); 11 exit( 1 ); 12} 13 14// ... 15 16// Free allocated memory: 17stdlib_ndarray_free( x );
The function accepts the following arguments:
[in] struct ndarray*
input ndarray.1void stdlib_ndarray_free( struct ndarray *arr );
Tests whether an ndarray has specified flags enabled.
1#include "stdlib/ndarray/ctor.h" 2#include <stdint.h> 3#include <stdlib.h> 4#include <stdio.h> 5 6// ... 7 8// Create an ndarray: 9struct ndarray *x = stdlib_ndarray_allocate( ... ); 10if ( x == NULL ) { 11 fprintf( stderr, "Error allocating memory.\n" ); 12 exit( 1 ); 13} 14 15// ... 16 17// Test whether an ndarray is row-major contiguous: 18int8_t out = stdlib_ndarray_flags( x, STDLIB_NDARRAY_ROW_MAJOR_CONTIGUOUS_FLAG ); 19 20// ... 21 22// Free allocated memory: 23stdlib_ndarray_free( x );
The function accepts the following arguments:
[in] struct ndarray*
input ndarray.[in] int64_t
bit mask specifying flags to test against.The function returns 1
if flags are set and 0
otherwise.
1int8_t stdlib_ndarray_has_flags( const struct ndarray *arr, const int64_t flags );
Returns the index mode of an ndarray.
1#include "stdlib/ndarray/ctor.h" 2#include "stdlib/ndarray/index_modes.h" 3#include <stdlib.h> 4#include <stdio.h> 5 6// ... 7 8// Create an ndarray: 9struct ndarray *x = stdlib_ndarray_allocate( ... ); 10if ( x == NULL ) { 11 fprintf( stderr, "Error allocating memory.\n" ); 12 exit( 1 ); 13} 14 15// ... 16 17// Retrieve the index mode: 18enum STDLIB_NDARRAY_INDEX_MODE imode = stdlib_ndarray_index_mode( x ); 19 20// ... 21 22// Free allocated memory: 23stdlib_ndarray_free( x );
The function accepts the following arguments:
[in] struct ndarray*
input ndarray.1int8_t stdlib_ndarray_index_mode( const struct ndarray *arr );
Returns the number of elements in an ndarray.
1#include "stdlib/ndarray/ctor.h" 2#include <stdint.h> 3#include <stdlib.h> 4#include <stdio.h> 5 6// ... 7 8// Create an ndarray: 9struct ndarray *x = stdlib_ndarray_allocate( ... ); 10if ( x == NULL ) { 11 fprintf( stderr, "Error allocating memory.\n" ); 12 exit( 1 ); 13} 14 15// ... 16 17// Retrieve the number of elements: 18int64_t N = stdlib_ndarray_length( x ); 19 20// ... 21 22// Free allocated memory: 23stdlib_ndarray_free( x );
The function accepts the following arguments:
[in] struct ndarray*
input ndarray.1int64_t stdlib_ndarray_length( const struct ndarray *arr );
Returns the number of ndarray dimensions.
1#include "stdlib/ndarray/ctor.h" 2#include <stdint.h> 3#include <stdlib.h> 4#include <stdio.h> 5 6// ... 7 8// Create an ndarray: 9struct ndarray *x = stdlib_ndarray_allocate( ... ); 10if ( x == NULL ) { 11 fprintf( stderr, "Error allocating memory.\n" ); 12 exit( 1 ); 13} 14 15// ... 16 17// Retrieve the number of dimensions: 18int64_t ndims = stdlib_ndarray_ndims( x ); 19 20// ... 21 22// Free allocated memory: 23stdlib_ndarray_free( x );
The function accepts the following arguments:
[in] struct ndarray*
input ndarray.1int64_t stdlib_ndarray_ndims( const struct ndarray *arr );
Returns the number of ndarray subscript modes.
1#include "stdlib/ndarray/ctor.h" 2#include <stdint.h> 3#include <stdlib.h> 4#include <stdio.h> 5 6// ... 7 8// Create an ndarray: 9struct ndarray *x = stdlib_ndarray_allocate( ... ); 10if ( x == NULL ) { 11 fprintf( stderr, "Error allocating memory.\n" ); 12 exit( 1 ); 13} 14 15// ... 16 17// Retrieve the number of index modes: 18int64_t n = stdlib_ndarray_nsubmodes( x ); 19 20// ... 21 22// Free allocated memory: 23stdlib_ndarray_free( x );
The function accepts the following arguments:
[in] struct ndarray*
input ndarray.1int64_t stdlib_ndarray_nsubmodes( const struct ndarray *arr );
Returns an ndarray index offset (in bytes).
1#include "stdlib/ndarray/ctor.h" 2#include <stdint.h> 3#include <stdlib.h> 4#include <stdio.h> 5 6// ... 7 8// Create an ndarray: 9struct ndarray *x = stdlib_ndarray_allocate( ... ); 10if ( x == NULL ) { 11 fprintf( stderr, "Error allocating memory.\n" ); 12 exit( 1 ); 13} 14 15// ... 16 17// Retrieve the index offset: 18int64_t offset = stdlib_ndarray_offset( x ); 19 20// ... 21 22// Free allocated memory: 23stdlib_ndarray_free( x );
The function accepts the following arguments:
[in] struct ndarray*
input ndarray.1int64_t stdlib_ndarray_offset( const struct ndarray *arr );
Returns the order of an ndarray.
1#include "stdlib/ndarray/ctor.h" 2#include "stdlib/ndarray/orders.h" 3#include <stdlib.h> 4#include <stdio.h> 5 6// ... 7 8// Create an ndarray: 9struct ndarray *x = stdlib_ndarray_allocate( ... ); 10if ( x == NULL ) { 11 fprintf( stderr, "Error allocating memory.\n" ); 12 exit( 1 ); 13} 14 15// ... 16 17// Retrieve the order: 18enum STDLIB_NDARRAY_ORDER order = stdlib_ndarray_order( x ); 19 20// ... 21 22// Free allocated memory: 23stdlib_ndarray_free( x );
The function accepts the following arguments:
[in] struct ndarray*
input ndarray.1int8_t stdlib_ndarray_order( const struct ndarray *arr );
Returns a pointer to an array containing an ndarray shape (dimensions).
1#include "stdlib/ndarray/ctor.h" 2#include <stdint.h> 3#include <stdlib.h> 4#include <stdio.h> 5 6// ... 7 8// Create an ndarray: 9struct ndarray *x = stdlib_ndarray_allocate( ... ); 10if ( x == NULL ) { 11 fprintf( stderr, "Error allocating memory.\n" ); 12 exit( 1 ); 13} 14 15// ... 16 17// Retrieve the shape: 18int64_t *shape = stdlib_ndarray_shape( x ); 19 20// ... 21 22// Free allocated memory: 23stdlib_ndarray_free( x );
The function accepts the following arguments:
[in] struct ndarray*
input ndarray.1int64_t * stdlib_ndarray_shape( const struct ndarray *arr );
Returns an ndarray stride (in bytes).
1#include "stdlib/ndarray/ctor.h" 2#include <stdint.h> 3#include <stdlib.h> 4#include <stdio.h> 5 6// ... 7 8// Create an ndarray: 9struct ndarray *x = stdlib_ndarray_allocate( ... ); 10if ( x == NULL ) { 11 fprintf( stderr, "Error allocating memory.\n" ); 12 exit( 1 ); 13} 14 15// ... 16 17// Retrieve a stride: 18int64_t s = stdlib_ndarray_stride( x, 0 ); 19 20// ... 21 22// Free allocated memory: 23stdlib_ndarray_free( x );
The function accepts the following arguments:
[in] struct ndarray*
input ndarray.[in] int64_t
dimension index.1int64_t stdlib_ndarray_stride( const struct ndarray *arr, const int64_t i );
Notes:
Returns a pointer to an array containing ndarray strides (in bytes).
1#include "stdlib/ndarray/ctor.h" 2#include <stdint.h> 3#include <stdlib.h> 4#include <stdio.h> 5 6// ... 7 8// Create an ndarray: 9struct ndarray *x = stdlib_ndarray_allocate( ... ); 10if ( x == NULL ) { 11 fprintf( stderr, "Error allocating memory.\n" ); 12 exit( 1 ); 13} 14 15// ... 16 17// Retrieve the strides: 18int64_t *strides = stdlib_ndarray_strides( x ); 19 20// ... 21 22// Free allocated memory: 23stdlib_ndarray_free( x );
The function accepts the following arguments:
[in] struct ndarray*
input ndarray.1int64_t * stdlib_ndarray_strides( const struct ndarray *arr );
Returns an ndarray subscript mode.
1#include "stdlib/ndarray/ctor.h" 2#include "stdlib/ndarray/index_modes.h" 3#include <stdlib.h> 4#include <stdio.h> 5 6// ... 7 8// Create an ndarray: 9struct ndarray *x = stdlib_ndarray_allocate( ... ); 10if ( x == NULL ) { 11 fprintf( stderr, "Error allocating memory.\n" ); 12 exit( 1 ); 13} 14 15// ... 16 17// Retrieve an index mode: 18enum STDLIB_NDARRAY_INDEX_MODE mode = stdlib_ndarray_submode( x, 0 ); 19 20// ... 21 22// Free allocated memory: 23stdlib_ndarray_free( x );
The function accepts the following arguments:
[in] struct ndarray*
input ndarray.[in] int64_t
dimension index.1int8_t stdlib_ndarray_submode( const struct ndarray *arr, const int64_t i );
Notes:
Returns ndarray subscript modes.
1#include "stdlib/ndarray/ctor.h" 2#include "stdlib/ndarray/index_modes.h" 3#include <stdlib.h> 4#include <stdio.h> 5 6// ... 7 8// Create an ndarray: 9struct ndarray *x = stdlib_ndarray_allocate( ... ); 10if ( x == NULL ) { 11 fprintf( stderr, "Error allocating memory.\n" ); 12 exit( 1 ); 13} 14 15// ... 16 17// Retrieve the index subscript modes: 18int8_t *modes = stdlib_ndarray_submodes( x ); 19 20// ... 21 22// Free allocated memory: 23stdlib_ndarray_free( x );
The function accepts the following arguments:
[in] struct ndarray*
input ndarray.1int8_t * stdlib_ndarray_submodes( const struct ndarray *arr );
Returns an ndarray data element.
1int8_t stdlib_ndarray_get( const struct ndarray *arr, const int64_t *sub, void *out );
The function accepts the following arguments:
[in] struct ndarray *
input ndarray.[in] int64_t *
ndarray subscripts.[out] void *
output address.Notes:
-1
if unable to get an element and 0
otherwise.void
pointer for the output address out
in order to provide a generic API supporting ndarrays having different data types.Returns a double-precision floating-point ndarray data element.
1int8_t stdlib_ndarray_get_float64( const struct ndarray *arr, const int64_t *sub, double *out );
The function accepts the following arguments:
[in] struct ndarray *
input ndarray.[in] int64_t *
ndarray subscripts.[out] double *
output address.Notes:
-1
if unable to get an element and 0
otherwise.Returns a single-precision floating-point ndarray data element.
1int8_t stdlib_ndarray_get_float32( const struct ndarray *arr, const int64_t *sub, float *out );
The function accepts the following arguments:
[in] struct ndarray *
input ndarray.[in] int64_t *
ndarray subscripts.[out] float *
output address.Notes:
-1
if unable to get an element and 0
otherwise.Returns an unsigned 64-bit integer ndarray data element.
1int8_t stdlib_ndarray_get_uint64( const struct ndarray *arr, const int64_t *sub, uint64_t *out );
The function accepts the following arguments:
[in] struct ndarray *
input ndarray.[in] int64_t *
ndarray subscripts.[out] uint64_t *
output address.Notes:
-1
if unable to get an element and 0
otherwise.Returns a signed 64-bit integer ndarray data element.
1int8_t stdlib_ndarray_get_int64( const struct ndarray *arr, const int64_t *sub, int64_t *out );
The function accepts the following arguments:
[in] struct ndarray *
input ndarray.[in] int64_t *
ndarray subscripts.[out] int64_t *
output address.Notes:
-1
if unable to get an element and 0
otherwise.Returns an unsigned 32-bit integer ndarray data element.
1int8_t stdlib_ndarray_get_uint32( const struct ndarray *arr, const int64_t *sub, uint32_t *out );
The function accepts the following arguments:
[in] struct ndarray *
input ndarray.[in] int64_t *
ndarray subscripts.[out] uint32_t *
output address.Notes:
-1
if unable to get an element and 0
otherwise.Returns a signed 32-bit integer ndarray data element.
1int8_t stdlib_ndarray_get_int32( const struct ndarray *arr, const int64_t *sub, int32_t *out );
The function accepts the following arguments:
[in] struct ndarray *
input ndarray.[in] int64_t *
ndarray subscripts.[out] int32_t *
output address.Notes:
-1
if unable to get an element and 0
otherwise.Returns an unsigned 16-bit integer ndarray data element.
1int8_t stdlib_ndarray_get_uint16( const struct ndarray *arr, const int64_t *sub, uint16_t *out );
The function accepts the following arguments:
[in] struct ndarray *
input ndarray.[in] int64_t *
ndarray subscripts.[out] uint16_t *
output address.Notes:
-1
if unable to get an element and 0
otherwise.Returns a signed 16-bit integer ndarray data element.
1int8_t stdlib_ndarray_get_int16( const struct ndarray *arr, const int64_t *sub, int16_t *out );
The function accepts the following arguments:
[in] struct ndarray *
input ndarray.[in] int64_t *
ndarray subscripts.[out] int16_t *
output address.Notes:
-1
if unable to get an element and 0
otherwise.Returns an unsigned 8-bit integer ndarray data element.
1int8_t stdlib_ndarray_get_uint8( const struct ndarray *arr, const int64_t *sub, uint8_t *out );
The function accepts the following arguments:
[in] struct ndarray *
input ndarray.[in] int64_t *
ndarray subscripts.[out] uint8_t *
output address.Notes:
-1
if unable to get an element and 0
otherwise.Returns a signed 8-bit integer ndarray data element.
1int8_t stdlib_ndarray_get_int8( const struct ndarray *arr, const int64_t *sub, int8_t *out );
The function accepts the following arguments:
[in] struct ndarray *
input ndarray.[in] int64_t *
ndarray subscripts.[out] int8_t *
output address.Notes:
-1
if unable to get an element and 0
otherwise.Returns a double-precision complex floating-point ndarray data element.
1int8_t stdlib_ndarray_get_complex128( const struct ndarray *arr, const int64_t *sub, stdlib_complex128_t *out );
The function accepts the following arguments:
[in] struct ndarray *
input ndarray.[in] int64_t *
ndarray subscripts.[out] stdlib_complex128_t *
output address.Notes:
-1
if unable to get an element and 0
otherwise.Returns a single-precision complex floating-point ndarray data element.
1int8_t stdlib_ndarray_get_complex64( const struct ndarray *arr, const int64_t *sub, stdlib_complex64_t *out );
The function accepts the following arguments:
[in] struct ndarray *
input ndarray.[in] int64_t *
ndarray subscripts.[out] stdlib_complex64_t *
output address.Notes:
-1
if unable to get an element and 0
otherwise.Returns a boolean ndarray data element.
1int8_t stdlib_ndarray_get_bool( const struct ndarray *arr, const int64_t *sub, bool *out );
The function accepts the following arguments:
[in] struct ndarray *
input ndarray.[in] int64_t *
ndarray subscripts.[out] bool *
output address.Notes:
-1
if unable to get an element and 0
otherwise.Returns a pointer to an ndarray data element in the underlying byte array.
1uint8_t * stdlib_ndarray_get_ptr( const struct ndarray *arr, const int64_t *sub );
The function accepts the following arguments:
[in] struct ndarray *
input ndarray.[in] int64_t *
ndarray subscripts.Returns an ndarray data element specified by a byte array pointer.
1int8_t stdlib_ndarray_get_ptr_value( const struct ndarray *arr, const uint8_t *idx, void *out );
The function accepts the following arguments:
[in] struct ndarray *
input ndarray.[in] uint8_t *
byte array pointer to an ndarray data element.[out] void *
output address.Notes:
-1
if unable to get an element and 0
otherwise.void
pointer for the output address out
in order to provide a generic API supporting ndarrays having different data types.Returns a double-precision floating-point ndarray data element specified by a byte array pointer.
1int8_t stdlib_ndarray_get_ptr_float64( const uint8_t *idx, double *out );
The function accepts the following arguments:
[in] uint8_t *
byte array pointer to an ndarray data element.[out] double *
output address.Notes:
idx
actually points to a compatible memory address. Accordingly, accessing unowned memory is possible, and this function assumes you know what you are doing.0
.Returns a single-precision floating-point ndarray data element specified by a byte array pointer.
1int8_t stdlib_ndarray_get_ptr_float32( const uint8_t *idx, float *out );
The function accepts the following arguments:
[in] uint8_t *
byte array pointer to an ndarray data element.[out] float *
output address.Notes:
idx
actually points to a compatible memory address. Accordingly, accessing unowned memory is possible, and this function assumes you know what you are doing.0
.Returns an unsigned 64-bit integer ndarray data element specified by a byte array pointer.
1int8_t stdlib_ndarray_get_ptr_uint64( const uint8_t *idx, uint64_t *out );
The function accepts the following arguments:
[in] uint8_t *
byte array pointer to an ndarray data element.[out] uint64_t *
output address.Notes:
idx
actually points to a compatible memory address. Accordingly, accessing unowned memory is possible, and this function assumes you know what you are doing.0
.Returns a signed 64-bit integer ndarray data element specified by a byte array pointer.
1int8_t stdlib_ndarray_get_ptr_int64( const uint8_t *idx, int64_t *out );
The function accepts the following arguments:
[in] uint8_t *
byte array pointer to an ndarray data element.[out] int64_t *
output address.Notes:
idx
actually points to a compatible memory address. Accordingly, accessing unowned memory is possible, and this function assumes you know what you are doing.0
.Returns an unsigned 32-bit integer ndarray data element specified by a byte array pointer.
1int8_t stdlib_ndarray_get_ptr_uint32( const uint8_t *idx, uint32_t *out );
The function accepts the following arguments:
[in] uint8_t *
byte array pointer to an ndarray data element.[out] uint32_t *
output address.Notes:
idx
actually points to a compatible memory address. Accordingly, accessing unowned memory is possible, and this function assumes you know what you are doing.0
.Returns a signed 32-bit integer ndarray data element specified by a byte array pointer.
1int8_t stdlib_ndarray_get_ptr_int32( const uint8_t *idx, int32_t *out );
The function accepts the following arguments:
[in] uint8_t *
byte array pointer to an ndarray data element.[out] int32_t *
output address.Notes:
idx
actually points to a compatible memory address. Accordingly, accessing unowned memory is possible, and this function assumes you know what you are doing.0
.Returns an unsigned 16-bit integer ndarray data element specified by a byte array pointer.
1int8_t stdlib_ndarray_get_ptr_uint16( const uint8_t *idx, uint16_t *out );
The function accepts the following arguments:
[in] uint8_t *
byte array pointer to an ndarray data element.[out] uint16_t *
output address.Notes:
idx
actually points to a compatible memory address. Accordingly, accessing unowned memory is possible, and this function assumes you know what you are doing.0
.Returns a signed 16-bit integer ndarray data element specified by a byte array pointer.
1int8_t stdlib_ndarray_get_ptr_int16( const uint8_t *idx, int16_t *out );
The function accepts the following arguments:
[in] uint8_t *
byte array pointer to an ndarray data element.[out] int16_t *
output address.Notes:
idx
actually points to a compatible memory address. Accordingly, accessing unowned memory is possible, and this function assumes you know what you are doing.0
.Returns an unsigned 8-bit integer ndarray data element specified by a byte array pointer.
1int8_t stdlib_ndarray_get_ptr_uint8( const uint8_t *idx, uint8_t *out );
The function accepts the following arguments:
[in] uint8_t *
byte array pointer to an ndarray data element.[out] uint8_t *
output address.Notes:
0
.Returns a signed 8-bit integer ndarray data element specified by a byte array pointer.
1int8_t stdlib_ndarray_get_ptr_int8( const uint8_t *idx, int8_t *out );
The function accepts the following arguments:
[in] uint8_t *
byte array pointer to an ndarray data element.[out] int8_t *
output address.Notes:
0
.Returns a double-precision complex floating-point ndarray data element specified by a byte array pointer.
1int8_t stdlib_ndarray_get_ptr_complex128( const uint8_t *idx, stdlib_complex128_t *out );
The function accepts the following arguments:
[in] uint8_t *
byte array pointer to an ndarray data element.[out] stdlib_complex128_t *
output address.Notes:
idx
actually points to a compatible memory address. Accordingly, accessing unowned memory is possible, and this function assumes you know what you are doing.0
.Returns a single-precision complex floating-point ndarray data element specified by a byte array pointer.
1int8_t stdlib_ndarray_get_ptr_complex64( const uint8_t *idx, stdlib_complex64_t *out );
The function accepts the following arguments:
[in] uint8_t *
byte array pointer to an ndarray data element.[out] stdlib_complex64_t *
output address.Notes:
idx
actually points to a compatible memory address. Accordingly, accessing unowned memory is possible, and this function assumes you know what you are doing.0
.Returns a boolean ndarray data element specified by a byte array pointer.
1int8_t stdlib_ndarray_get_ptr_bool( const uint8_t *idx, bool *out );
The function accepts the following arguments:
[in] uint8_t *
byte array pointer to an ndarray data element.[out] bool *
output address.Notes:
idx
actually points to a compatible memory address. Accordingly, accessing unowned memory is possible, and this function assumes you know what you are doing.0
.Returns an ndarray data element located at a specified linear index.
1int8_t stdlib_ndarray_iget( const struct ndarray *arr, const int64_t idx, void *out );
The function accepts the following arguments:
[in] struct ndarray*
input ndarray.[in] int64_t
linear view index.[out] void *
output address.Notes:
-1
if unable to get an element and 0
otherwise.void
pointer for the output address out
in order to provide a generic API supporting ndarrays having different data types.idx
.Returns a double-precision floating-point ndarray data element located at a specified linear index.
1int8_t stdlib_ndarray_iget_float64( const struct ndarray *arr, const int64_t idx, double *out );
The function accepts the following arguments:
[in] struct ndarray*
input ndarray.[in] int64_t
linear view index.[out] double *
output address.Notes:
-1
if unable to get an element and 0
otherwise.idx
.Returns a single-precision floating-point ndarray data element located at a specified linear index.
1int8_t stdlib_ndarray_iget_float32( const struct ndarray *arr, const int64_t idx, float *out );
The function accepts the following arguments:
[in] struct ndarray*
input ndarray.[in] int64_t
linear view index.[out] float *
output address.Notes:
-1
if unable to get an element and 0
otherwise.idx
.Returns an unsigned 64-bit integer ndarray data element located at a specified linear index.
1int8_t stdlib_ndarray_iget_uint64( const struct ndarray *arr, const int64_t idx, uint64_t *out );
The function accepts the following arguments:
[in] struct ndarray*
input ndarray.[in] int64_t
linear view index.[out] uint64_t *
output address.Notes:
-1
if unable to get an element and 0
otherwise.idx
.Returns a signed 64-bit integer ndarray data element located at a specified linear index.
1int8_t stdlib_ndarray_iget_int64( const struct ndarray *arr, const int64_t idx, int64_t *out );
The function accepts the following arguments:
[in] struct ndarray*
input ndarray.[in] int64_t
linear view index.[out] int64_t *
output address.Notes:
-1
if unable to get an element and 0
otherwise.idx
.Returns an unsigned 32-bit integer ndarray data element located at a specified linear index.
1int8_t stdlib_ndarray_iget_uint32( const struct ndarray *arr, const int64_t idx, uint32_t *out );
The function accepts the following arguments:
[in] struct ndarray*
input ndarray.[in] int64_t
linear view index.[out] uint32_t *
output address.Notes:
-1
if unable to get an element and 0
otherwise.idx
.Returns a signed 32-bit integer ndarray data element located at a specified linear index.
1int8_t stdlib_ndarray_iget_int32( const struct ndarray *arr, const int64_t idx, int32_t *out );
The function accepts the following arguments:
[in] struct ndarray*
input ndarray.[in] int64_t
linear view index.[out] int32_t *
output address.Notes:
-1
if unable to get an element and 0
otherwise.No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
1 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no SAST tool detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
project is not fuzzed
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More